File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
src/test/kotlin/io/element/android/libraries/matrix/impl/util Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ dependencies {
4747 testImplementation(libs.test.truth)
4848 testImplementation(libs.test.robolectric)
4949 testImplementation(projects.libraries.matrix.test)
50+ testImplementation(projects.libraries.sessionStorage.implMemory)
51+ testImplementation(projects.libraries.sessionStorage.test)
5052 testImplementation(projects.services.analytics.test)
5153 testImplementation(projects.services.toolbox.test)
5254 testImplementation(projects.tests.testutils)
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2024 New Vector Ltd.
3+ *
4+ * SPDX-License-Identifier: AGPL-3.0-only
5+ * Please see LICENSE in the repository root for full details.
6+ */
7+
8+ package io.element.android.libraries.matrix.impl.util
9+
10+ import com.google.common.truth.Truth.assertThat
11+ import io.element.android.libraries.matrix.test.A_SESSION_ID
12+ import io.element.android.libraries.sessionstorage.impl.memory.InMemorySessionStore
13+ import io.element.android.libraries.sessionstorage.test.aSessionData
14+ import kotlinx.coroutines.test.runTest
15+ import org.junit.Test
16+
17+ class SessionPathsProviderTest {
18+ @Test
19+ fun `if session is not found, provides returns null` () = runTest {
20+ val sut = SessionPathsProvider (InMemorySessionStore ())
21+ val result = sut.provides(A_SESSION_ID )
22+ assertThat(result).isNull()
23+ }
24+
25+ @Test
26+ fun `if session is found, provides returns the data` () = runTest {
27+ val store = InMemorySessionStore ()
28+ val sut = SessionPathsProvider (store)
29+ store.storeData(
30+ aSessionData(
31+ sessionPath = " /a/path/to/a/session" ,
32+ cachePath = " /a/path/to/a/cache" ,
33+ )
34+ )
35+ val result = sut.provides(A_SESSION_ID )!!
36+ assertThat(result.fileDirectory.absolutePath).isEqualTo(" /a/path/to/a/session" )
37+ assertThat(result.cacheDirectory.absolutePath).isEqualTo(" /a/path/to/a/cache" )
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments