Skip to content

Commit a6d50a1

Browse files
authored
Add test for missing SessionCoordinator code coverage (#10680)
1 parent dbdd950 commit a6d50a1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

FirebaseSessions/Tests/Unit/SessionCoordinatorTests.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,30 @@ class SessionCoordinatorTests: XCTestCase {
9494
XCTAssertEqual(fireLogger.loggedEvent, event)
9595
XCTAssertFalse(resultSuccess)
9696
}
97+
98+
func test_attemptLoggingSessionStart_handlesInstallationsError() throws {
99+
installations.result = .failure(NSError(domain: "TestInstallationsError", code: -1))
100+
101+
let sessionInfo = SessionInfo(
102+
sessionId: "testSessionId",
103+
previousSessionId: "testPreviousSessionId",
104+
dispatchEvents: true
105+
)
106+
let event = SessionStartEvent(sessionInfo: sessionInfo, appInfo: appInfo, time: time)
107+
108+
// Start success so it must be set to false
109+
var resultSuccess = true
110+
coordinator.attemptLoggingSessionStart(event: event) { result in
111+
switch result {
112+
case .success(()):
113+
resultSuccess = true
114+
case .failure:
115+
resultSuccess = false
116+
}
117+
}
118+
119+
// We should have logged the event, but with a failed result
120+
XCTAssertNil(fireLogger.loggedEvent)
121+
XCTAssertFalse(resultSuccess)
122+
}
97123
}

0 commit comments

Comments
 (0)