From e91de9258a9068e8bd8f73e7da2cdc57983fe5d3 Mon Sep 17 00:00:00 2001 From: Michael Lehenbauer Date: Wed, 2 May 2018 14:54:51 -0700 Subject: 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. --- .../Tests/Integration/API/FIRCursorTests.mm | 23 ++++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'Firestore') 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" ])); } -- cgit v1.2.3