File tree Expand file tree Collapse file tree 1 file changed +4
-10
lines changed
Tests/AWSLambdaRuntimeTests Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -16,29 +16,23 @@ import Testing
1616
1717@testable import AWSLambdaRuntime
1818
19- #if canImport(FoundationEssentials)
20- import FoundationEssentials
21- #else
22- import Foundation
23- #endif
24-
2519struct UtilsTest {
2620 @Test
2721 func testGenerateXRayTraceID( ) {
28- // the time and identifier should be in hexadecimal digits
29- let invalidCharacters = CharacterSet ( charactersIn: " abcdef0123456789 " ) . inverted
3022 let numTests = 1000
3123 var values = Set < String > ( )
3224 for _ in 0 ..< numTests {
25+ // the time and identifier should be in hexadecimal digits
26+ let allowedCharacters = " 0123456789abcdef "
3327 // check the format, see https://docs.aws.amazon.com/xray/latest/devguide/xray-api-sendingdata.html#xray-api-traceids)
3428 let traceId = AmazonHeaders . generateXRayTraceID ( )
3529 let segments = traceId. split ( separator: " - " )
3630 #expect( segments. count == 3 )
3731 #expect( segments [ 0 ] == " 1 " )
3832 #expect( segments [ 1 ] . count == 8 )
39- #expect( segments [ 1 ] . rangeOfCharacter ( from: invalidCharacters) == nil )
4033 #expect( segments [ 2 ] . count == 24 )
41- #expect( segments [ 2 ] . rangeOfCharacter ( from: invalidCharacters) == nil )
34+ #expect( segments [ 1 ] . allSatisfy { allowedCharacters. contains ( $0) } )
35+ #expect( segments [ 2 ] . allSatisfy { allowedCharacters. contains ( $0) } )
4236 values. insert ( traceId)
4337 }
4438 // check that the generated values are different
You can’t perform that action at this time.
0 commit comments