mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Add Konsist test to check Metro annotation.
This commit is contained in:
committed by
Benoit Marty
parent
81739d2b8a
commit
0f479c1947
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.tests.konsist
|
||||||
|
|
||||||
|
import com.lemonappdev.konsist.api.Konsist
|
||||||
|
import com.lemonappdev.konsist.api.ext.list.withAnnotationOf
|
||||||
|
import com.lemonappdev.konsist.api.ext.list.withParameter
|
||||||
|
import com.lemonappdev.konsist.api.verify.assertTrue
|
||||||
|
import dev.zacsweers.metro.Assisted
|
||||||
|
import dev.zacsweers.metro.Inject
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class KonsistDiTest {
|
||||||
|
@Test
|
||||||
|
fun `class annotated with @Inject should not have constructors with @Assisted parameter`() {
|
||||||
|
Konsist
|
||||||
|
.scopeFromProject()
|
||||||
|
.classes()
|
||||||
|
.withAnnotationOf(Inject::class)
|
||||||
|
.assertTrue(
|
||||||
|
additionalMessage = "Class with @Assisted parameter in constructor should be annotated with @AssistedInject and not @Inject"
|
||||||
|
) { classDeclaration ->
|
||||||
|
classDeclaration.constructors
|
||||||
|
.withParameter { parameterDeclaration ->
|
||||||
|
parameterDeclaration.hasAnnotationOf(Assisted::class)
|
||||||
|
}
|
||||||
|
.isEmpty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user