Skip to content

Commit a7f7cf4

Browse files
authored
More tests on dates with fractional seconds (#106)
Based on the discussion here swiftlang/swift-foundation#1561 (comment) , I added a few more tests around dates with fractional seconds
1 parent 213b75d commit a7f7cf4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Tests/AWSLambdaEventsTests/S3Tests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ struct S3Tests {
112112
#expect(record.awsRegion == .eu_central_1)
113113
#expect(record.eventName == "ObjectCreated:Put")
114114
#expect(record.eventTime.ISO8601Format() == Date(timeIntervalSince1970: 1_578_907_540.621).ISO8601Format())
115+
// see https://github.com/swiftlang/swift-foundation/issues/1561#issuecomment-3448853449
116+
#expect(abs(record.eventTime.timeIntervalSince1970 - 1_578_907_540.621) < 0.0005)
115117
#expect(record.userIdentity == S3Event.UserIdentity(principalId: "AWS:AAAAAAAJ2MQ4YFQZ7AULJ"))
116118
#expect(record.requestParameters == S3Event.RequestParameters(sourceIPAddress: "123.123.123.123"))
117119
#expect(record.responseElements.count == 2)
@@ -136,6 +138,8 @@ struct S3Tests {
136138
#expect(record.awsRegion == .eu_central_1)
137139
#expect(record.eventName == "ObjectRemoved:DeleteMarkerCreated")
138140
#expect(record.eventTime.ISO8601Format() == Date(timeIntervalSince1970: 1_578_907_540.621).ISO8601Format())
141+
// see https://github.com/swiftlang/swift-foundation/issues/1561#issuecomment-3448853449
142+
#expect(abs(record.eventTime.timeIntervalSince1970 - 1_578_907_540.621) < 0.0005)
139143
#expect(record.userIdentity == S3Event.UserIdentity(principalId: "AWS:AAAAAAAJ2MQ4YFQZ7AULJ"))
140144
#expect(record.requestParameters == S3Event.RequestParameters(sourceIPAddress: "123.123.123.123"))
141145
#expect(record.responseElements.count == 2)

Tests/AWSLambdaEventsTests/Utils/DateWrapperTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ struct DateWrapperTests {
6868
#if swift(<6.2)
6969
let error = (any Error).self
7070
#else
71+
#if canImport(FoundationEssentials)
7172
let error = Never.self
73+
#else
74+
let error = (any Error).self
75+
#endif
7276
#endif
7377
#expect(throws: error) {
7478
try JSONDecoder().decode(TestEvent.self, from: json.data(using: .utf8)!)

0 commit comments

Comments
 (0)