Clear unused and fix tests
This commit is contained in:
@@ -7,8 +7,6 @@ interface PreferencesStorage {
|
||||
|
||||
val baseUrlKey: Preferences.Key<String>
|
||||
|
||||
val authHeaderKey: Preferences.Key<String>
|
||||
|
||||
val isDisclaimerAcceptedKey: Preferences.Key<Boolean>
|
||||
|
||||
suspend fun <T> getValue(key: Preferences.Key<T>): T?
|
||||
|
||||
@@ -17,8 +17,6 @@ class PreferencesStorageImpl @Inject constructor(
|
||||
|
||||
override val baseUrlKey = stringPreferencesKey("baseUrl")
|
||||
|
||||
override val authHeaderKey = stringPreferencesKey("authHeader")
|
||||
|
||||
override val isDisclaimerAcceptedKey = booleanPreferencesKey("isDisclaimedAccepted")
|
||||
|
||||
override suspend fun <T> getValue(key: Preferences.Key<T>): T? {
|
||||
|
||||
@@ -31,7 +31,8 @@ interface AuthModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAuthServiceFactory(retrofitBuilder: RetrofitBuilder,
|
||||
fun provideAuthServiceFactory(
|
||||
retrofitBuilder: RetrofitBuilder,
|
||||
baseURLStorage: BaseURLStorage,
|
||||
): ServiceFactory<AuthService> = retrofitBuilder.createServiceFactory(baseURLStorage)
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package gq.kirmanak.mealient.ui.auth
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
class AuthenticatorActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.auth.AuthenticatorActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/toolbar_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:liftOnScroll="true">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/Widget.MaterialComponents.Toolbar.Primary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?actionBarSize"
|
||||
app:layout_scrollFlags="scroll|snap" />
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/nav_host"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:defaultNavHost="true"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/toolbar_holder"
|
||||
app:navGraph="@navigation/authenticator_graph" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/authenticator_graph"
|
||||
app:startDestination="@id/authenticationFragment2">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/authenticationFragment2"
|
||||
android:name="gq.kirmanak.mealient.ui.auth.AuthenticationFragment"
|
||||
android:label="fragment_authentication"
|
||||
tools:layout="@layout/fragment_authentication" />
|
||||
</navigation>
|
||||
@@ -32,7 +32,7 @@ class AuthDataSourceImplTest {
|
||||
fun setUp() {
|
||||
MockKAnnotations.init(this)
|
||||
subject = AuthDataSourceImpl(authServiceFactory, NetworkModule.createJson())
|
||||
coEvery { authServiceFactory.provideService() } returns authService
|
||||
coEvery { authServiceFactory.provideService(any(), eq(false)) } returns authService
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,7 +71,9 @@ class AuthDataSourceImplTest {
|
||||
|
||||
@Test(expected = MalformedUrl::class)
|
||||
fun `when authenticate and provideService throws then MalformedUrl`() = runTest {
|
||||
coEvery { authServiceFactory.provideService() } throws MalformedUrl(RuntimeException())
|
||||
coEvery {
|
||||
authServiceFactory.provideService(any(), eq(false))
|
||||
} throws MalformedUrl(RuntimeException())
|
||||
callAuthenticate()
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class RetrofitServiceFactoryTest {
|
||||
fun setUp() {
|
||||
MockKAnnotations.init(this)
|
||||
subject = retrofitBuilder.createServiceFactory(baseURLStorage)
|
||||
coEvery { retrofitBuilder.buildRetrofit(any()) } returns retrofit
|
||||
coEvery { retrofitBuilder.buildRetrofit(any(), eq(true)) } returns retrofit
|
||||
every { retrofit.create(eq(VersionService::class.java)) } returns versionService
|
||||
coEvery { baseURLStorage.requireBaseURL() } returns TEST_BASE_URL
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class RetrofitServiceFactoryTest {
|
||||
fun `when provideService called twice then builder called once`() = runTest {
|
||||
subject.provideService()
|
||||
subject.provideService()
|
||||
coVerifyAll { retrofitBuilder.buildRetrofit(eq(TEST_BASE_URL)) }
|
||||
coVerifyAll { retrofitBuilder.buildRetrofit(eq(TEST_BASE_URL), eq(true)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -61,8 +61,8 @@ class RetrofitServiceFactoryTest {
|
||||
subject.provideService()
|
||||
subject.provideService("new url")
|
||||
coVerifyAll {
|
||||
retrofitBuilder.buildRetrofit(eq(TEST_BASE_URL))
|
||||
retrofitBuilder.buildRetrofit(eq("new url"))
|
||||
retrofitBuilder.buildRetrofit(eq(TEST_BASE_URL), eq(true))
|
||||
retrofitBuilder.buildRetrofit(eq("new url"), eq(true))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,30 +18,30 @@ class PreferencesStorageImplTest : HiltRobolectricTest() {
|
||||
|
||||
@Test
|
||||
fun `when getValue without writes then null`() = runTest {
|
||||
assertThat(subject.getValue(subject.authHeaderKey)).isNull()
|
||||
assertThat(subject.getValue(subject.baseUrlKey)).isNull()
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException::class)
|
||||
fun `when requireValue without writes then throws IllegalStateException`() = runTest {
|
||||
subject.requireValue(subject.authHeaderKey)
|
||||
subject.requireValue(subject.baseUrlKey)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when getValue after write then returns value`() = runTest {
|
||||
subject.storeValues(Pair(subject.authHeaderKey, "test"))
|
||||
assertThat(subject.getValue(subject.authHeaderKey)).isEqualTo("test")
|
||||
subject.storeValues(Pair(subject.baseUrlKey, "test"))
|
||||
assertThat(subject.getValue(subject.baseUrlKey)).isEqualTo("test")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when storeValue then valueUpdates emits`() = runTest {
|
||||
subject.storeValues(Pair(subject.authHeaderKey, "test"))
|
||||
assertThat(subject.valueUpdates(subject.authHeaderKey).first()).isEqualTo("test")
|
||||
subject.storeValues(Pair(subject.baseUrlKey, "test"))
|
||||
assertThat(subject.valueUpdates(subject.baseUrlKey).first()).isEqualTo("test")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when remove value then getValue returns null`() = runTest {
|
||||
subject.storeValues(Pair(subject.authHeaderKey, "test"))
|
||||
subject.removeValues(subject.authHeaderKey)
|
||||
assertThat(subject.getValue(subject.authHeaderKey)).isNull()
|
||||
subject.storeValues(Pair(subject.baseUrlKey, "test"))
|
||||
subject.removeValues(subject.baseUrlKey)
|
||||
assertThat(subject.getValue(subject.baseUrlKey)).isNull()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user