Fix quality issue and add tests.
This commit is contained in:
parent
b345f0eb8e
commit
4c77201a4e
4 changed files with 51 additions and 4 deletions
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
package io.element.android.features.enterprise.api
|
package io.element.android.features.enterprise.api
|
||||||
|
|
||||||
|
import io.element.android.libraries.matrix.api.core.SessionId
|
||||||
|
|
||||||
interface EnterpriseService {
|
interface EnterpriseService {
|
||||||
suspend fun isEnterpriseUser(): Boolean
|
val isEnterpriseBuild: Boolean
|
||||||
|
suspend fun isEnterpriseUser(sessionId: SessionId): Boolean
|
||||||
}
|
}
|
||||||
|
|
@ -27,4 +27,10 @@ dependencies {
|
||||||
api(libs.anvil.compiler.api)
|
api(libs.anvil.compiler.api)
|
||||||
api(projects.features.enterprise.api)
|
api(projects.features.enterprise.api)
|
||||||
implementation(projects.libraries.architecture)
|
implementation(projects.libraries.architecture)
|
||||||
|
implementation(projects.libraries.matrix.api)
|
||||||
|
|
||||||
|
testImplementation(libs.coroutines.test)
|
||||||
|
testImplementation(libs.test.junit)
|
||||||
|
testImplementation(libs.test.truth)
|
||||||
|
testImplementation(projects.libraries.matrix.test)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,13 @@ package io.element.android.features.enterprise.impl
|
||||||
|
|
||||||
import com.squareup.anvil.annotations.ContributesBinding
|
import com.squareup.anvil.annotations.ContributesBinding
|
||||||
import io.element.android.features.enterprise.api.EnterpriseService
|
import io.element.android.features.enterprise.api.EnterpriseService
|
||||||
import io.element.android.libraries.di.SessionScope
|
import io.element.android.libraries.di.AppScope
|
||||||
|
import io.element.android.libraries.matrix.api.core.SessionId
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ContributesBinding(SessionScope::class)
|
@ContributesBinding(AppScope::class)
|
||||||
class DefaultEnterpriseService @Inject constructor(
|
class DefaultEnterpriseService @Inject constructor(
|
||||||
|
override val isEnterpriseBuild: Boolean = false
|
||||||
) : EnterpriseService {
|
) : EnterpriseService {
|
||||||
override suspend fun isEnterpriseUser(): Boolean = false
|
override suspend fun isEnterpriseUser(sessionId: SessionId) = false
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.enterprise.impl
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.libraries.matrix.test.A_SESSION_ID
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultEnterpriseServiceTest {
|
||||||
|
@Test
|
||||||
|
fun `isEnterpriseBuild is false`() {
|
||||||
|
val defaultEnterpriseService = DefaultEnterpriseService()
|
||||||
|
assertThat(defaultEnterpriseService.isEnterpriseBuild).isFalse()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `isEnterpriseUser always return false`() = runTest {
|
||||||
|
val defaultEnterpriseService = DefaultEnterpriseService()
|
||||||
|
assertThat(defaultEnterpriseService.isEnterpriseUser(A_SESSION_ID)).isFalse()
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue