Rename classes overriding classes from the FFI layer. (#4817)

* Rename classes overriding classes from the FFI layer.

* For other Konsist test.
This commit is contained in:
Benoit Marty 2025-06-04 16:13:57 +02:00 committed by GitHub
parent 3ae8d77c9a
commit 7a3db35ccb
43 changed files with 155 additions and 143 deletions

View file

@ -15,6 +15,7 @@ import com.lemonappdev.konsist.api.ext.list.withAllParentsOf
import com.lemonappdev.konsist.api.ext.list.withAnnotationNamed
import com.lemonappdev.konsist.api.ext.list.withNameContaining
import com.lemonappdev.konsist.api.ext.list.withNameEndingWith
import com.lemonappdev.konsist.api.ext.list.withPackage
import com.lemonappdev.konsist.api.ext.list.withoutName
import com.lemonappdev.konsist.api.ext.list.withoutNameStartingWith
import com.lemonappdev.konsist.api.verify.assertEmpty
@ -89,9 +90,9 @@ class KonsistClassNameTest {
)
.assertTrue {
val interfaceName = it.name
.replace("FakeRust", "")
.replace("FakeFfi", "")
.replace("Fake", "")
val result = (it.name.startsWith("Fake") || it.name.startsWith("FakeRust")) &&
val result = it.name.startsWith("Fake") &&
it.parents().any { parent ->
val parentName = parent.name.replace(".", "")
parentName == interfaceName
@ -106,6 +107,17 @@ class KonsistClassNameTest {
assertThat(failingCases).isEqualTo(failingCasesList.size)
}
@Test
fun `All Classes that override a class from the Ffi layer must have 'FakeFfi' prefix`() {
Konsist.scopeFromTest()
.classes()
.withPackage("io.element.android.libraries.matrix.impl.fixtures.fakes")
.assertTrue { klass ->
val parentName = klass.parents().firstOrNull()?.name.orEmpty()
klass.name == "FakeFfi$parentName"
}
}
@Test
fun `Class implementing interface should have name not end with 'Impl' but start with 'Default'`() {
Konsist.scopeFromProject()