Skip to content

Commit

Permalink
Improved flush policy interval test.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsneed committed Nov 16, 2023
1 parent 3ab0792 commit 3a42e48
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Tests/Segment-Tests/FlushPolicy_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,15 @@ class FlushPolicyTests: XCTestCase {

XCTAssertTrue(analytics.hasUnsentEvents)

// sleep for 4 seconds for 2 second flush policy
RunLoop.main.run(until: Date.init(timeIntervalSinceNow: 4))

XCTAssertFalse(analytics.hasUnsentEvents)
@Atomic var flushSent = false
while !flushSent {
RunLoop.main.run(until: Date.distantPast)
if analytics.pendingUploads!.count > 0 {
// flush was triggered
flushSent = true
}
}

XCTAssertTrue(flushSent)
}
}

0 comments on commit 3a42e48

Please sign in to comment.