Skip to content

Commit 4df2df4

Browse files
committed
DataConnectAuthUnitTest.kt: add tests for calling forceRefresh() and getToken() before initialize()`
1 parent 8253350 commit 4df2df4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

firebase-dataconnect/src/test/kotlin/com/google/firebase/dataconnect/core/DataConnectAuthUnitTest.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,30 @@ class DataConnectAuthUnitTest {
223223
dataConnectAuth.forceRefresh()
224224
}
225225

226+
@Test
227+
fun `forceRefresh() should throw if invoked before initialize() close()`() = runTest {
228+
val dataConnectAuth = newDataConnectAuth()
229+
230+
val exception = shouldThrow<IllegalStateException> { dataConnectAuth.forceRefresh() }
231+
232+
assertSoftly {
233+
exception.message shouldContainWithNonAbuttingText "forceRefresh()"
234+
exception.message shouldContainWithNonAbuttingTextIgnoringCase "initialize() must be called"
235+
}
236+
}
237+
238+
@Test
239+
fun `getToken() should throw if invoked before initialize() close()`() = runTest {
240+
val dataConnectAuth = newDataConnectAuth()
241+
242+
val exception = shouldThrow<IllegalStateException> { dataConnectAuth.getToken(requestId) }
243+
244+
assertSoftly {
245+
exception.message shouldContainWithNonAbuttingText "getToken()"
246+
exception.message shouldContainWithNonAbuttingTextIgnoringCase "initialize() must be called"
247+
}
248+
}
249+
226250
@Test
227251
fun `getToken() should return null if InternalAuthProvider is not available`() = runTest {
228252
val dataConnectAuth = newDataConnectAuth(deferredInternalAuthProvider = UnavailableDeferred())

0 commit comments

Comments
 (0)