From 519688efebbc1b314a893c42b24037ad32597fd6 Mon Sep 17 00:00:00 2001 From: tom doron Date: Tue, 21 Apr 2020 13:34:11 -0700 Subject: [PATCH 1/7] add a testing harness to ease testing of lambdas motivation: make testing lambda easy changes: * add a AWSLambdaTesting module * add helper methods for testing different types of Lambda handlers / closures --- Package.swift | 10 ++ Sources/AWSLambdaTesting/Lambda+Testing.swift | 61 ++++++++++ Tests/AWSLambdaTestingTests/Tests.swift | 114 ++++++++++++++++++ 3 files changed, 185 insertions(+) create mode 100644 Sources/AWSLambdaTesting/Lambda+Testing.swift create mode 100644 Tests/AWSLambdaTestingTests/Tests.swift diff --git a/Package.swift b/Package.swift index cdd1453a..fe41b346 100644 --- a/Package.swift +++ b/Package.swift @@ -8,8 +8,12 @@ let package = Package( .macOS(.v10_13), ], products: [ + // core library .library(name: "AWSLambdaRuntime", targets: ["AWSLambdaRuntime"]), + // common AWS events .library(name: "AWSLambdaEvents", targets: ["AWSLambdaEvents"]), + // for testing only + .library(name: "AWSLambdaTesting", targets: ["AWSLambdaTesting"]), ], dependencies: [ .package(url: "https://github.com/apple/swift-nio.git", from: "2.8.0"), @@ -26,6 +30,12 @@ let package = Package( .testTarget(name: "AWSLambdaRuntimeTests", dependencies: ["AWSLambdaRuntime"]), .target(name: "AWSLambdaEvents", dependencies: []), .testTarget(name: "AWSLambdaEventsTests", dependencies: ["AWSLambdaEvents"]), + // testing helper + .target(name: "AWSLambdaTesting", dependencies: [ + "AWSLambdaRuntime", + .product(name: "NIOHTTP1", package: "swift-nio"), + ]), + .testTarget(name: "AWSLambdaTestingTests", dependencies: ["AWSLambdaTesting"]), // samples .target(name: "StringSample", dependencies: ["AWSLambdaRuntime"]), .target(name: "CodableSample", dependencies: ["AWSLambdaRuntime"]), diff --git a/Sources/AWSLambdaTesting/Lambda+Testing.swift b/Sources/AWSLambdaTesting/Lambda+Testing.swift new file mode 100644 index 00000000..64fa23fd --- /dev/null +++ b/Sources/AWSLambdaTesting/Lambda+Testing.swift @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the SwiftAWSLambdaRuntime open source project +// +// Copyright (c) 2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + +// @testable for access of internal functions - this would only work for testing by design +@testable import AWSLambdaRuntime +import Dispatch +import Logging +import NIO + +extension Lambda { + public static func test(_ closure: @escaping StringLambdaClosure, + with payload: String, + _ body: @escaping (Result) -> Void) { + Self.test(StringLambdaClosureWrapper(closure), with: payload, body) + } + + public static func test(_ closure: @escaping StringVoidLambdaClosure, + with payload: String, + _ body: @escaping (Result) -> Void) { + Self.test(StringVoidLambdaClosureWrapper(closure), with: payload, body) + } + + public static func test(_ closure: @escaping CodableLambdaClosure, + with payload: In, + _ body: @escaping (Result) -> Void) { + Self.test(CodableLambdaClosureWrapper(closure), with: payload, body) + } + + public static func test(_ closure: @escaping CodableVoidLambdaClosure, + with payload: In, + _ body: @escaping (Result) -> Void) { + Self.test(CodableVoidLambdaClosureWrapper(closure), with: payload, body) + } + + public static func test(_ handler: Handler, + with payload: In, + _ body: @escaping (Result) -> Void) where Handler.In == In, Handler.Out == Out { + let logger = Logger(label: "test") + let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1) + let context = Context(requestId: "\(DispatchTime.now().uptimeNanoseconds)", + traceId: "Root=\(DispatchTime.now().uptimeNanoseconds);Parent=\(DispatchTime.now().uptimeNanoseconds);Sampled=1", + invokedFunctionArn: "arn:aws:lambda:us-west-1:\(DispatchTime.now().uptimeNanoseconds):function:custom-runtime", + deadline: .now() + 5, + logger: logger, + eventLoop: eventLoopGroup.next()) + handler.handle(context: context, payload: payload).whenComplete { result in + body(result) + } + } +} diff --git a/Tests/AWSLambdaTestingTests/Tests.swift b/Tests/AWSLambdaTestingTests/Tests.swift new file mode 100644 index 00000000..2e32d730 --- /dev/null +++ b/Tests/AWSLambdaTestingTests/Tests.swift @@ -0,0 +1,114 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the SwiftAWSLambdaRuntime open source project +// +// Copyright (c) 2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + +import AWSLambdaRuntime +import AWSLambdaTesting +import XCTest + +class LambdaTestingTests: XCTestCase { + func testCodableClosure() { + struct Request: Codable { + let name: String + } + + struct Response: Codable { + let message: String + } + + let myLambda = { (_: Lambda.Context, request: Request, callback: (Result) -> Void) in + callback(.success(Response(message: "echo" + request.name))) + } + + let request = Request(name: UUID().uuidString) + Lambda.test(myLambda, with: request) { result in + switch result { + case .failure(let error): + XCTFail("expected to succeed but failed with \(error)") + case .success(let response): + XCTAssertEqual(response.message, "echo" + request.name) + } + } + } + + func testCodableVoidClosure() { + struct Request: Codable { + let name: String + } + + let myLambda = { (_: Lambda.Context, _: Request, callback: (Result) -> Void) in + callback(.success(())) + } + + let request = Request(name: UUID().uuidString) + Lambda.test(myLambda, with: request) { result in + switch result { + case .failure(let error): + XCTFail("expected to succeed but failed with \(error)") + case .success: + break + } + } + } + + func testLambdaHandler() { + struct Request: Codable { + let name: String + } + + struct Response: Codable { + let message: String + } + + struct MyLambda: LambdaHandler { + typealias In = Request + typealias Out = Response + + func handle(context: Lambda.Context, payload: In, callback: @escaping (Result) -> Void) { + callback(.success(Response(message: "echo" + payload.name))) + } + } + + let request = Request(name: UUID().uuidString) + Lambda.test(MyLambda(), with: request) { result in + switch result { + case .failure(let error): + XCTFail("expected to succeed but failed with \(error)") + case .success(let response): + XCTAssertEqual(response.message, "echo" + request.name) + } + } + } + + func testFailure() { + struct MyError: Error {} + + struct MyLambda: LambdaHandler { + typealias In = String + typealias Out = Void + + func handle(context: Lambda.Context, payload: In, callback: @escaping (Result) -> Void) { + callback(.failure(MyError())) + } + } + + Lambda.test(MyLambda(), with: UUID().uuidString) { result in + switch result { + case .failure(let error): + XCTAssert(error is MyError) + case .success: + XCTFail("expected to fail but succeeded") + } + } + } +} From 57b4274551388b236f014062977d270564049bc1 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Wed, 22 Apr 2020 16:54:46 +0200 Subject: [PATCH 2/7] Some improvements --- Package.swift | 2 +- Sources/AWSLambdaTesting/Lambda+Testing.swift | 75 +++++++++++----- Tests/AWSLambdaTestingTests/Tests.swift | 88 +++++++++++++------ 3 files changed, 112 insertions(+), 53 deletions(-) diff --git a/Package.swift b/Package.swift index fe41b346..624cf6b5 100644 --- a/Package.swift +++ b/Package.swift @@ -33,7 +33,7 @@ let package = Package( // testing helper .target(name: "AWSLambdaTesting", dependencies: [ "AWSLambdaRuntime", - .product(name: "NIOHTTP1", package: "swift-nio"), + .product(name: "NIO", package: "swift-nio"), ]), .testTarget(name: "AWSLambdaTestingTests", dependencies: ["AWSLambdaTesting"]), // samples diff --git a/Sources/AWSLambdaTesting/Lambda+Testing.swift b/Sources/AWSLambdaTesting/Lambda+Testing.swift index 64fa23fd..6f9e3ab6 100644 --- a/Sources/AWSLambdaTesting/Lambda+Testing.swift +++ b/Sources/AWSLambdaTesting/Lambda+Testing.swift @@ -19,43 +19,70 @@ import Logging import NIO extension Lambda { + public struct TestConfig { + public var requestId: String + public var traceId: String + public var invokedFunctionArn: String + public var timeout: Double + + public init(requestId: String = "\(DispatchTime.now().uptimeNanoseconds)", + traceId: String = "Root=\(DispatchTime.now().uptimeNanoseconds);Parent=\(DispatchTime.now().uptimeNanoseconds);Sampled=1", + invokedFunctionArn: String = "arn:aws:lambda:us-west-1:\(DispatchTime.now().uptimeNanoseconds):function:custom-runtime", + timeout: Double = 5) { + self.requestId = requestId + self.traceId = traceId + self.invokedFunctionArn = invokedFunctionArn + self.timeout = timeout + } + } + public static func test(_ closure: @escaping StringLambdaClosure, - with payload: String, - _ body: @escaping (Result) -> Void) { - Self.test(StringLambdaClosureWrapper(closure), with: payload, body) + config: TestConfig = .init(), + with payload: String) throws -> String { + try Self.test(StringLambdaClosureWrapper(closure), config: config, with: payload) } public static func test(_ closure: @escaping StringVoidLambdaClosure, - with payload: String, - _ body: @escaping (Result) -> Void) { - Self.test(StringVoidLambdaClosureWrapper(closure), with: payload, body) + config: TestConfig = .init(), + with payload: String) throws { + _ = try Self.test(StringVoidLambdaClosureWrapper(closure), config: config, with: payload) } - public static func test(_ closure: @escaping CodableLambdaClosure, - with payload: In, - _ body: @escaping (Result) -> Void) { - Self.test(CodableLambdaClosureWrapper(closure), with: payload, body) + public static func test( + _ closure: @escaping CodableLambdaClosure, + config: TestConfig = .init(), + with payload: In + ) throws -> Out { + try Self.test(CodableLambdaClosureWrapper(closure), config: config, with: payload) } public static func test(_ closure: @escaping CodableVoidLambdaClosure, - with payload: In, - _ body: @escaping (Result) -> Void) { - Self.test(CodableVoidLambdaClosureWrapper(closure), with: payload, body) + config: TestConfig = .init(), + with payload: In) throws { + _ = try Self.test(CodableVoidLambdaClosureWrapper(closure), config: config, with: payload) } - public static func test(_ handler: Handler, - with payload: In, - _ body: @escaping (Result) -> Void) where Handler.In == In, Handler.Out == Out { + public static func test( + _ handler: Handler, + config: TestConfig = .init(), + with payload: In + ) throws -> Out where Handler.In == In, Handler.Out == Out { let logger = Logger(label: "test") let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1) - let context = Context(requestId: "\(DispatchTime.now().uptimeNanoseconds)", - traceId: "Root=\(DispatchTime.now().uptimeNanoseconds);Parent=\(DispatchTime.now().uptimeNanoseconds);Sampled=1", - invokedFunctionArn: "arn:aws:lambda:us-west-1:\(DispatchTime.now().uptimeNanoseconds):function:custom-runtime", - deadline: .now() + 5, + let eventLoop = eventLoopGroup.next() + + let context = Context(requestId: config.requestId, + traceId: config.traceId, + invokedFunctionArn: config.invokedFunctionArn, + deadline: .now() + config.timeout, logger: logger, - eventLoop: eventLoopGroup.next()) - handler.handle(context: context, payload: payload).whenComplete { result in - body(result) - } + eventLoop: eventLoop) + + let result = try eventLoop.flatSubmit { + handler.handle(context: context, payload: payload) + }.wait() + + try eventLoopGroup.syncShutdownGracefully() + return result } } diff --git a/Tests/AWSLambdaTestingTests/Tests.swift b/Tests/AWSLambdaTestingTests/Tests.swift index 2e32d730..f52f1cb0 100644 --- a/Tests/AWSLambdaTestingTests/Tests.swift +++ b/Tests/AWSLambdaTestingTests/Tests.swift @@ -14,6 +14,7 @@ import AWSLambdaRuntime import AWSLambdaTesting +import NIO import XCTest class LambdaTestingTests: XCTestCase { @@ -31,14 +32,9 @@ class LambdaTestingTests: XCTestCase { } let request = Request(name: UUID().uuidString) - Lambda.test(myLambda, with: request) { result in - switch result { - case .failure(let error): - XCTFail("expected to succeed but failed with \(error)") - case .success(let response): - XCTAssertEqual(response.message, "echo" + request.name) - } - } + var response: Response? + XCTAssertNoThrow(response = try Lambda.test(myLambda, with: request)) + XCTAssertEqual(response?.message, "echo" + request.name) } func testCodableVoidClosure() { @@ -51,14 +47,7 @@ class LambdaTestingTests: XCTestCase { } let request = Request(name: UUID().uuidString) - Lambda.test(myLambda, with: request) { result in - switch result { - case .failure(let error): - XCTFail("expected to succeed but failed with \(error)") - case .success: - break - } - } + XCTAssertNoThrow(try Lambda.test(myLambda, with: request)) } func testLambdaHandler() { @@ -75,19 +64,32 @@ class LambdaTestingTests: XCTestCase { typealias Out = Response func handle(context: Lambda.Context, payload: In, callback: @escaping (Result) -> Void) { + XCTAssertFalse(context.eventLoop.inEventLoop) callback(.success(Response(message: "echo" + payload.name))) } } let request = Request(name: UUID().uuidString) - Lambda.test(MyLambda(), with: request) { result in - switch result { - case .failure(let error): - XCTFail("expected to succeed but failed with \(error)") - case .success(let response): - XCTAssertEqual(response.message, "echo" + request.name) + var response: Response? + XCTAssertNoThrow(response = try Lambda.test(MyLambda(), with: request)) + XCTAssertEqual(response?.message, "echo" + request.name) + } + + func testEventLoopLambdaHandler() { + struct MyLambda: EventLoopLambdaHandler { + typealias In = String + typealias Out = String + + func handle(context: Lambda.Context, payload: String) -> EventLoopFuture { + XCTAssertTrue(context.eventLoop.inEventLoop) + return context.eventLoop.makeSucceededFuture("echo" + payload) } } + + let input = UUID().uuidString + var result: String? + XCTAssertNoThrow(result = try Lambda.test(MyLambda(), with: input)) + XCTAssertEqual(result, "echo" + input) } func testFailure() { @@ -102,13 +104,43 @@ class LambdaTestingTests: XCTestCase { } } - Lambda.test(MyLambda(), with: UUID().uuidString) { result in - switch result { - case .failure(let error): - XCTAssert(error is MyError) - case .success: - XCTFail("expected to fail but succeeded") + XCTAssertThrowsError(try Lambda.test(MyLambda(), with: UUID().uuidString)) { error in + XCTAssert(error is MyError) + } + } + + func testAsyncLongRunning() { + var executed: Bool = false + let myLambda = { (_: Lambda.Context, _: String, callback: @escaping (Result) -> Void) in + DispatchQueue.global(qos: .background).asyncAfter(deadline: .now() + 0.5) { + executed = true + callback(.success(())) } } + + XCTAssertNoThrow(try Lambda.test(myLambda, with: UUID().uuidString)) + XCTAssertTrue(executed) + } + + func testConfigValues() { + let config = Lambda.TestConfig( + requestId: "abc123", + traceId: "hahahihi", + invokedFunctionArn: "arn:hihi", + timeout: 4 + ) + + let myLambda = { (ctx: Lambda.Context, _: String, callback: @escaping (Result) -> Void) in + XCTAssertEqual(ctx.requestId, config.requestId) + XCTAssertEqual(ctx.traceId, config.traceId) + XCTAssertEqual(ctx.invokedFunctionArn, config.invokedFunctionArn) + + let secondsSinceEpoch = Double(Int64(bitPattern: ctx.deadline.rawValue)) / -1_000_000_000 + XCTAssertLessThanOrEqual(Date(timeIntervalSince1970: secondsSinceEpoch).timeIntervalSinceNow, config.timeout) + + callback(.success(())) + } + + XCTAssertNoThrow(try Lambda.test(myLambda, config: config, with: UUID().uuidString)) } } From 67c9d7216e8e22f1b31f5a78df05b0852e80f9f1 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Wed, 22 Apr 2020 23:52:24 +0200 Subject: [PATCH 3/7] Fixed syntax. Now `using config` --- Sources/AWSLambdaTesting/Lambda+Testing.swift | 24 ++++++++++--------- Tests/AWSLambdaTestingTests/Tests.swift | 7 +++--- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Sources/AWSLambdaTesting/Lambda+Testing.swift b/Sources/AWSLambdaTesting/Lambda+Testing.swift index 6f9e3ab6..49edb60f 100644 --- a/Sources/AWSLambdaTesting/Lambda+Testing.swift +++ b/Sources/AWSLambdaTesting/Lambda+Testing.swift @@ -23,12 +23,12 @@ extension Lambda { public var requestId: String public var traceId: String public var invokedFunctionArn: String - public var timeout: Double + public var timeout: DispatchTimeInterval public init(requestId: String = "\(DispatchTime.now().uptimeNanoseconds)", traceId: String = "Root=\(DispatchTime.now().uptimeNanoseconds);Parent=\(DispatchTime.now().uptimeNanoseconds);Sampled=1", invokedFunctionArn: String = "arn:aws:lambda:us-west-1:\(DispatchTime.now().uptimeNanoseconds):function:custom-runtime", - timeout: Double = 5) { + timeout: DispatchTimeInterval = .seconds(5)) { self.requestId = requestId self.traceId = traceId self.invokedFunctionArn = invokedFunctionArn @@ -37,28 +37,30 @@ extension Lambda { } public static func test(_ closure: @escaping StringLambdaClosure, - config: TestConfig = .init(), - with payload: String) throws -> String { + with payload: String, + using config: TestConfig = .init()) throws -> String { try Self.test(StringLambdaClosureWrapper(closure), config: config, with: payload) } public static func test(_ closure: @escaping StringVoidLambdaClosure, - config: TestConfig = .init(), - with payload: String) throws { + with payload: String, + using config: TestConfig = .init()) throws { _ = try Self.test(StringVoidLambdaClosureWrapper(closure), config: config, with: payload) } public static func test( _ closure: @escaping CodableLambdaClosure, - config: TestConfig = .init(), - with payload: In + with payload: In, + using config: TestConfig = .init() ) throws -> Out { try Self.test(CodableLambdaClosureWrapper(closure), config: config, with: payload) } - public static func test(_ closure: @escaping CodableVoidLambdaClosure, - config: TestConfig = .init(), - with payload: In) throws { + public static func test( + _ closure: @escaping CodableVoidLambdaClosure, + with payload: In, + using config: TestConfig = .init() + ) throws { _ = try Self.test(CodableVoidLambdaClosureWrapper(closure), config: config, with: payload) } diff --git a/Tests/AWSLambdaTestingTests/Tests.swift b/Tests/AWSLambdaTestingTests/Tests.swift index f52f1cb0..7061fb0b 100644 --- a/Tests/AWSLambdaTestingTests/Tests.swift +++ b/Tests/AWSLambdaTestingTests/Tests.swift @@ -123,11 +123,12 @@ class LambdaTestingTests: XCTestCase { } func testConfigValues() { + let timeout: TimeInterval = 4 let config = Lambda.TestConfig( requestId: "abc123", traceId: "hahahihi", invokedFunctionArn: "arn:hihi", - timeout: 4 + timeout: .seconds(4) ) let myLambda = { (ctx: Lambda.Context, _: String, callback: @escaping (Result) -> Void) in @@ -136,11 +137,11 @@ class LambdaTestingTests: XCTestCase { XCTAssertEqual(ctx.invokedFunctionArn, config.invokedFunctionArn) let secondsSinceEpoch = Double(Int64(bitPattern: ctx.deadline.rawValue)) / -1_000_000_000 - XCTAssertLessThanOrEqual(Date(timeIntervalSince1970: secondsSinceEpoch).timeIntervalSinceNow, config.timeout) + XCTAssertEqual(Date(timeIntervalSince1970: secondsSinceEpoch).timeIntervalSinceNow, timeout, accuracy: 0.1) callback(.success(())) } - XCTAssertNoThrow(try Lambda.test(myLambda, config: config, with: UUID().uuidString)) + XCTAssertNoThrow(try Lambda.test(myLambda, with: UUID().uuidString, using: config)) } } From 4c85713c950f6fbfb9d63ce00399bc4ebad6affa Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Thu, 23 Apr 2020 08:31:56 +0200 Subject: [PATCH 4/7] final fixes --- Sources/AWSLambdaTesting/Lambda+Testing.swift | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Sources/AWSLambdaTesting/Lambda+Testing.swift b/Sources/AWSLambdaTesting/Lambda+Testing.swift index 49edb60f..7fa71221 100644 --- a/Sources/AWSLambdaTesting/Lambda+Testing.swift +++ b/Sources/AWSLambdaTesting/Lambda+Testing.swift @@ -39,13 +39,13 @@ extension Lambda { public static func test(_ closure: @escaping StringLambdaClosure, with payload: String, using config: TestConfig = .init()) throws -> String { - try Self.test(StringLambdaClosureWrapper(closure), config: config, with: payload) + try Self.test(StringLambdaClosureWrapper(closure), with: payload, using: config) } public static func test(_ closure: @escaping StringVoidLambdaClosure, with payload: String, using config: TestConfig = .init()) throws { - _ = try Self.test(StringVoidLambdaClosureWrapper(closure), config: config, with: payload) + _ = try Self.test(StringVoidLambdaClosureWrapper(closure), with: payload, using: config) } public static func test( @@ -53,7 +53,7 @@ extension Lambda { with payload: In, using config: TestConfig = .init() ) throws -> Out { - try Self.test(CodableLambdaClosureWrapper(closure), config: config, with: payload) + try Self.test(CodableLambdaClosureWrapper(closure), with: payload, using: config) } public static func test( @@ -61,18 +61,20 @@ extension Lambda { with payload: In, using config: TestConfig = .init() ) throws { - _ = try Self.test(CodableVoidLambdaClosureWrapper(closure), config: config, with: payload) + _ = try Self.test(CodableVoidLambdaClosureWrapper(closure), with: payload, using: config) } public static func test( _ handler: Handler, - config: TestConfig = .init(), - with payload: In + with payload: In, + using config: TestConfig = .init() ) throws -> Out where Handler.In == In, Handler.Out == Out { let logger = Logger(label: "test") let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1) + defer { + try! eventLoopGroup.syncShutdownGracefully() + } let eventLoop = eventLoopGroup.next() - let context = Context(requestId: config.requestId, traceId: config.traceId, invokedFunctionArn: config.invokedFunctionArn, @@ -80,11 +82,8 @@ extension Lambda { logger: logger, eventLoop: eventLoop) - let result = try eventLoop.flatSubmit { + return try eventLoop.flatSubmit { handler.handle(context: context, payload: payload) }.wait() - - try eventLoopGroup.syncShutdownGracefully() - return result } } From ebc17ee165061ae2e80fa1d390c1a648a4be4e14 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Thu, 23 Apr 2020 09:07:42 +0200 Subject: [PATCH 5/7] Update Tests/AWSLambdaTestingTests/Tests.swift Co-Authored-By: tomer doron --- Tests/AWSLambdaTestingTests/Tests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/AWSLambdaTestingTests/Tests.swift b/Tests/AWSLambdaTestingTests/Tests.swift index 7061fb0b..9671c05c 100644 --- a/Tests/AWSLambdaTestingTests/Tests.swift +++ b/Tests/AWSLambdaTestingTests/Tests.swift @@ -125,7 +125,7 @@ class LambdaTestingTests: XCTestCase { func testConfigValues() { let timeout: TimeInterval = 4 let config = Lambda.TestConfig( - requestId: "abc123", + requestId: UUID().uuidString, traceId: "hahahihi", invokedFunctionArn: "arn:hihi", timeout: .seconds(4) From 27428fd6637db5514f011f6c4c82b92ca4409da7 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Thu, 23 Apr 2020 09:07:50 +0200 Subject: [PATCH 6/7] Update Tests/AWSLambdaTestingTests/Tests.swift Co-Authored-By: tomer doron --- Tests/AWSLambdaTestingTests/Tests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/AWSLambdaTestingTests/Tests.swift b/Tests/AWSLambdaTestingTests/Tests.swift index 9671c05c..cb206691 100644 --- a/Tests/AWSLambdaTestingTests/Tests.swift +++ b/Tests/AWSLambdaTestingTests/Tests.swift @@ -126,7 +126,7 @@ class LambdaTestingTests: XCTestCase { let timeout: TimeInterval = 4 let config = Lambda.TestConfig( requestId: UUID().uuidString, - traceId: "hahahihi", + traceId: UUID().uuidString, invokedFunctionArn: "arn:hihi", timeout: .seconds(4) ) From bd035f7ad86ead891ad882211bfc1ca9a3eb1e6f Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Thu, 23 Apr 2020 09:07:57 +0200 Subject: [PATCH 7/7] Update Tests/AWSLambdaTestingTests/Tests.swift Co-Authored-By: tomer doron --- Tests/AWSLambdaTestingTests/Tests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/AWSLambdaTestingTests/Tests.swift b/Tests/AWSLambdaTestingTests/Tests.swift index cb206691..9db7b9b8 100644 --- a/Tests/AWSLambdaTestingTests/Tests.swift +++ b/Tests/AWSLambdaTestingTests/Tests.swift @@ -127,7 +127,7 @@ class LambdaTestingTests: XCTestCase { let config = Lambda.TestConfig( requestId: UUID().uuidString, traceId: UUID().uuidString, - invokedFunctionArn: "arn:hihi", + invokedFunctionArn: "arn:\(UUID().uuidString)", timeout: .seconds(4) )