Skip to content

Commit

Permalink
Use Swift Testing for InvocationTests (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianfett authored Sep 6, 2024
1 parent 757815b commit 0dcb143
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,26 @@
//
//===----------------------------------------------------------------------===//

import Foundation
import NIOHTTP1
import XCTest
import Testing

@testable import AWSLambdaRuntimeCore

class InvocationTest: XCTestCase {
@Suite
struct InvocationTest {
@Test
func testInvocationTraceID() throws {
let headers = HTTPHeaders([
(AmazonHeaders.requestID, "test"),
(AmazonHeaders.deadline, String(Date(timeIntervalSinceNow: 60).millisSinceEpoch)),
(AmazonHeaders.invokedFunctionARN, "arn:aws:lambda:us-east-1:123456789012:function:custom-runtime"),
])

var invocation: InvocationMetadata?
var maybeInvocation: InvocationMetadata?

XCTAssertNoThrow(invocation = try InvocationMetadata(headers: headers))
XCTAssertNotNil(invocation)

guard !invocation!.traceID.isEmpty else {
XCTFail("Invocation traceID is empty")
return
}
#expect(throws: Never.self) { maybeInvocation = try InvocationMetadata(headers: headers) }
let invocation = try #require(maybeInvocation)
#expect(!invocation.traceID.isEmpty)
}
}

0 comments on commit 0dcb143

Please sign in to comment.