Skip to content

Commit

Permalink
Other Es -> EnvironmentVariable
Browse files Browse the repository at this point in the history
  • Loading branch information
mgacy committed Jan 26, 2024
1 parent f576960 commit fa5e0f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions Sources/LambdaMocks/MockContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Logging
import NIOCore

/// A mock function context for testing.
public struct MockContext<E>: RuntimeContext, EnvironmentValueProvider {
public struct MockContext<EnvironmentVariable>: RuntimeContext, EnvironmentValueProvider {
public var requestID: String
public var traceID: String
public var invokedFunctionARN: String
Expand All @@ -29,7 +29,7 @@ public struct MockContext<E>: RuntimeContext, EnvironmentValueProvider {
public var remainingTimeProvider: @Sendable (DispatchWallTime) -> TimeAmount

/// A closure returning the value of the given environment variable.
public var environmentValueProvider: @Sendable (E) throws -> String
public var environmentValueProvider: @Sendable (EnvironmentVariable) throws -> String

/// Creates a new instance.
///
Expand Down Expand Up @@ -57,7 +57,7 @@ public struct MockContext<E>: RuntimeContext, EnvironmentValueProvider {
eventLoop: EventLoop,
allocator: ByteBufferAllocator,
remainingTimeProvider: @escaping @Sendable (DispatchWallTime) -> TimeAmount,
environmentValueProvider: @escaping @Sendable (E) throws -> String
environmentValueProvider: @escaping @Sendable (EnvironmentVariable) throws -> String
) {
self.requestID = requestID
self.traceID = traceID
Expand All @@ -76,7 +76,7 @@ public struct MockContext<E>: RuntimeContext, EnvironmentValueProvider {
remainingTimeProvider(deadline)
}

public func value(for environmentVariable: E) throws -> String {
public func value(for environmentVariable: EnvironmentVariable) throws -> String {
try environmentValueProvider(environmentVariable)
}
}
Expand Down Expand Up @@ -154,7 +154,7 @@ public extension MockContext {
logger: Logger = .mock,
allocator: ByteBufferAllocator = .init(),
remainingTimeProvider: @escaping @Sendable (DispatchWallTime) -> TimeAmount = Self.timeAmountUntil,
environmentValueProvider: @escaping @Sendable (E) throws -> String
environmentValueProvider: @escaping @Sendable (EnvironmentVariable) throws -> String
) {
self.requestID = configuration.requestID
self.traceID = configuration.traceID
Expand Down
8 changes: 4 additions & 4 deletions Sources/LambdaMocks/MockInitializationContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Logging
import NIOCore

/// A mock initialization context for testing.
public class MockInitializationContext<E>: InitializationContext, EnvironmentValueProvider, @unchecked Sendable {
public class MockInitializationContext<EnvironmentVariable>: InitializationContext, EnvironmentValueProvider, @unchecked Sendable {
public let logger: Logger
public let eventLoop: EventLoop
public let allocator: ByteBufferAllocator
Expand All @@ -20,7 +20,7 @@ public class MockInitializationContext<E>: InitializationContext, EnvironmentVal
public var handlers: [(EventLoop) -> EventLoopFuture<Void>] = []

/// A closure returning the value of the given environment variable.
private var environmentValueProvider: @Sendable (E) throws -> String
private var environmentValueProvider: @Sendable (EnvironmentVariable) throws -> String

/// Creates a new instance.
///
Expand All @@ -36,7 +36,7 @@ public class MockInitializationContext<E>: InitializationContext, EnvironmentVal
eventLoop: EventLoop,
allocator: ByteBufferAllocator,
handlers: [(EventLoop) -> EventLoopFuture<Void>] = [],
environmentValueProvider: @escaping @Sendable (E) throws -> String
environmentValueProvider: @escaping @Sendable (EnvironmentVariable) throws -> String
) {
self.logger = logger
self.eventLoop = eventLoop
Expand All @@ -49,7 +49,7 @@ public class MockInitializationContext<E>: InitializationContext, EnvironmentVal
handlers.append(handler)
}

public func value(for environmentVariable: E) throws -> String {
public func value(for environmentVariable: EnvironmentVariable) throws -> String {
try environmentValueProvider(environmentVariable)
}

Expand Down

0 comments on commit fa5e0f0

Please sign in to comment.