Rename API and update test.
This commit is contained in:
parent
65d682f8ca
commit
80fa442b64
4 changed files with 9 additions and 7 deletions
|
|
@ -33,7 +33,7 @@ class DatabaseSessionStore(
|
|||
) : SessionStore {
|
||||
private val sessionDataMutex = Mutex()
|
||||
|
||||
override fun isLoggedIn(): Flow<LoggedInState> {
|
||||
override fun loggedInStateFlow(): Flow<LoggedInState> {
|
||||
return database.sessionDataQueries.selectFirst()
|
||||
.asFlow()
|
||||
.mapToOneOrNull(dispatchers.io)
|
||||
|
|
|
|||
|
|
@ -54,12 +54,14 @@ class DatabaseSessionStoreTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `isLoggedIn emits true while there are sessions in the DB`() = runTest {
|
||||
databaseSessionStore.isLoggedIn().test {
|
||||
fun `loggedInStateFlow emits LoggedIn while there are sessions in the DB`() = runTest {
|
||||
databaseSessionStore.loggedInStateFlow().test {
|
||||
assertThat(awaitItem()).isEqualTo(LoggedInState.NotLoggedIn)
|
||||
database.sessionDataQueries.insertSessionData(aSessionData)
|
||||
databaseSessionStore.addSession(aSessionData.toApiModel())
|
||||
assertThat(awaitItem()).isEqualTo(LoggedInState.LoggedIn(sessionId = aSessionData.userId, isTokenValid = true))
|
||||
database.sessionDataQueries.removeSession(aSessionData.userId)
|
||||
// TODO add more sessions in multi-account PR.
|
||||
// Remove the first session
|
||||
databaseSessionStore.removeSession(aSessionData.userId)
|
||||
assertThat(awaitItem()).isEqualTo(LoggedInState.NotLoggedIn)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue