diff options
author | Michael Lehenbauer <mikelehen@gmail.com> | 2018-05-02 14:54:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-02 14:54:51 -0700 |
commit | e91de9258a9068e8bd8f73e7da2cdc57983fe5d3 (patch) | |
tree | 85ae82215a2bcc3ea2a7dc404a09705036982953 /Firestore | |
parent | de70bd5ef70c978454a7829d2d33added124fb7c (diff) |
b/78539022: Fix test at risk of range violation errors depending on time-of-day. (#1213)
micros could underflow or overflow if the test was run at the wrong time... Replaced with hardcoded timestamps as I don't think making it time-dependent gains us interesting additional coverage.
Diffstat (limited to 'Firestore')
-rw-r--r-- | Firestore/Example/Tests/Integration/API/FIRCursorTests.mm | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/Firestore/Example/Tests/Integration/API/FIRCursorTests.mm b/Firestore/Example/Tests/Integration/API/FIRCursorTests.mm index 2188b8a..e444d7a 100644 --- a/Firestore/Example/Tests/Integration/API/FIRCursorTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRCursorTests.mm @@ -216,32 +216,29 @@ FIRTimestamp *TimestampWithMicros(int64_t seconds, int32_t micros) { } - (void)testTimestampsCanBePassedToQueriesInWhereClause { - FIRTimestamp *currentTimestamp = [FIRTimestamp timestamp]; - int64_t seconds = currentTimestamp.seconds; - int32_t micros = currentTimestamp.nanoseconds / 1000; FIRCollectionReference *testCollection = [self collectionRefWithDocuments:@{ @"a" : @{ - @"timestamp" : TimestampWithMicros(seconds, micros + 2), + @"timestamp" : TimestampWithMicros(100, 7), }, @"b" : @{ - @"timestamp" : TimestampWithMicros(seconds, micros - 1), + @"timestamp" : TimestampWithMicros(100, 4), }, @"c" : @{ - @"timestamp" : TimestampWithMicros(seconds, micros + 3), + @"timestamp" : TimestampWithMicros(100, 8), }, @"d" : @{ - @"timestamp" : TimestampWithMicros(seconds, micros), + @"timestamp" : TimestampWithMicros(100, 5), }, @"e" : @{ - @"timestamp" : TimestampWithMicros(seconds, micros + 1), + @"timestamp" : TimestampWithMicros(100, 6), } }]; - FIRQuerySnapshot *querySnapshot = [self - readDocumentSetForRef:[[testCollection queryWhereField:@"timestamp" - isGreaterThanOrEqualTo:TimestampWithMicros(seconds, micros)] - queryWhereField:@"timestamp" - isLessThan:TimestampWithMicros(seconds, micros + 3)]]; + FIRQuerySnapshot *querySnapshot = + [self readDocumentSetForRef:[[testCollection queryWhereField:@"timestamp" + isGreaterThanOrEqualTo:TimestampWithMicros(100, 5)] + queryWhereField:@"timestamp" + isLessThan:TimestampWithMicros(100, 8)]]; XCTAssertEqualObjects(FIRQuerySnapshotGetIDs(querySnapshot), (@[ @"d", @"e", @"a" ])); } |