Skip to content

Commit

Permalink
fixup! feat: introduce a writeQueue for event tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklasl committed May 24, 2024
1 parent 900c5cd commit d4cf2e3
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions Tests/ConfidenceTests/EventSenderEngineTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ final class EventSenderEngineTest: XCTestCase {
}

func testManualFlushWorks() throws {
let writeExpectation = self.expectation(description: "Writes handled")
let eventSenderEngine = EventSenderEngineImpl(
clientSecret: "CLIENT_SECRET",
uploader: uploaderMock,
Expand All @@ -163,18 +162,11 @@ final class EventSenderEngineTest: XCTestCase {
eventSenderEngine.emit(eventName: "Hello", message: [:], context: [:])


writeQueue.async {
// Give some time for the events to be processed
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
writeExpectation.fulfill()
}
writeQueue.sync {
XCTAssertEqual(storageMock.events.count, 4)
XCTAssertNil(uploaderMock.calledRequest)
}

waitForExpectations(timeout: 1.0, handler: nil)

XCTAssertEqual(storageMock.events.count, 4)
XCTAssertNil(uploaderMock.calledRequest)

eventSenderEngine.flush()

let uploadExpectation = XCTestExpectation(description: "Upload finished")
Expand Down

0 comments on commit d4cf2e3

Please sign in to comment.