From 0bace75879622bfa07a6e09f59d5b6ba98bcb37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Fri, 29 Sep 2023 20:10:05 +0200 Subject: [PATCH] Add test ensure all composables are in compose package --- .../test/arch/classes/DataClassTests.kt | 17 +++++++++++++++++ .../test/arch/compose/ComposeTests.kt | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/classes/DataClassTests.kt create mode 100644 android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposeTests.kt diff --git a/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/classes/DataClassTests.kt b/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/classes/DataClassTests.kt new file mode 100644 index 000000000000..248eef5a1006 --- /dev/null +++ b/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/classes/DataClassTests.kt @@ -0,0 +1,17 @@ +package net.mullvad.mullvadvpn.test.arch.classes + +import com.lemonappdev.konsist.api.ext.list.modifierprovider.withDataModifier +import com.lemonappdev.konsist.api.verify.assert +import net.mullvad.mullvadvpn.test.arch.extensions.projectScope +import org.junit.Ignore +import org.junit.Test + +class DataClasses { + @Ignore("Code needs clean up") + @Test + fun `data classes use only immutable parameters`() { + projectScope().classes(includeNested = true).withDataModifier().assert { + it.properties(includeNested = true).all { property -> property.hasValModifier } + } + } +} diff --git a/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposeTests.kt b/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposeTests.kt new file mode 100644 index 000000000000..24e9ff9fc8cf --- /dev/null +++ b/android/test/arch/src/test/kotlin/net/mullvad/mullvadvpn/test/arch/compose/ComposeTests.kt @@ -0,0 +1,19 @@ +package net.mullvad.mullvadvpn.test.arch.compose + +import androidx.compose.runtime.Composable +import com.lemonappdev.konsist.api.Konsist +import com.lemonappdev.konsist.api.ext.list.withAllAnnotationsOf +import com.lemonappdev.konsist.api.verify.assert +import org.junit.Test + +class ComposeTests { + @Test + fun `all app composables are in the compose packages`() { + allAppComposeFunctions().assert { + it.fullyQualifiedName.startsWith("net.mullvad.mullvadvpn.compose") + } + } + + private fun allAppComposeFunctions() = + Konsist.scopeFromProduction("app").functions().withAllAnnotationsOf(Composable::class) +}