From 754c78330d03391d295b54074e9bb6d695f25dc0 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Fri, 6 Sep 2024 12:30:16 +0200 Subject: [PATCH] Use Swift testing for InvocationTests --- ...questTests.swift => InvocationTests.swift} | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) rename Tests/AWSLambdaRuntimeCoreTests/{ControlPlaneRequestTests.swift => InvocationTests.swift} (73%) diff --git a/Tests/AWSLambdaRuntimeCoreTests/ControlPlaneRequestTests.swift b/Tests/AWSLambdaRuntimeCoreTests/InvocationTests.swift similarity index 73% rename from Tests/AWSLambdaRuntimeCoreTests/ControlPlaneRequestTests.swift rename to Tests/AWSLambdaRuntimeCoreTests/InvocationTests.swift index 013cf9d8..86bfaae9 100644 --- a/Tests/AWSLambdaRuntimeCoreTests/ControlPlaneRequestTests.swift +++ b/Tests/AWSLambdaRuntimeCoreTests/InvocationTests.swift @@ -12,12 +12,15 @@ // //===----------------------------------------------------------------------===// +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"), @@ -25,14 +28,10 @@ class InvocationTest: XCTestCase { (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) } }