Skip to content

Commit 3a42e48

Browse files
committed
Improved flush policy interval test.
1 parent 3ab0792 commit 3a42e48

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Tests/Segment-Tests/FlushPolicy_Tests.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,15 @@ class FlushPolicyTests: XCTestCase {
137137

138138
XCTAssertTrue(analytics.hasUnsentEvents)
139139

140-
// sleep for 4 seconds for 2 second flush policy
141-
RunLoop.main.run(until: Date.init(timeIntervalSinceNow: 4))
142-
143-
XCTAssertFalse(analytics.hasUnsentEvents)
140+
@Atomic var flushSent = false
141+
while !flushSent {
142+
RunLoop.main.run(until: Date.distantPast)
143+
if analytics.pendingUploads!.count > 0 {
144+
// flush was triggered
145+
flushSent = true
146+
}
147+
}
148+
149+
XCTAssertTrue(flushSent)
144150
}
145151
}

0 commit comments

Comments
 (0)