Skip to content

Commit

Permalink
Add konsist tests for management service to avoid missing Either
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Jul 24, 2024
1 parent 47f8365 commit ac826a8
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.mullvad.mullvadvpn.test.arch

import com.lemonappdev.konsist.api.Konsist
import com.lemonappdev.konsist.api.ext.list.modifierprovider.withPublicOrDefaultModifier
import com.lemonappdev.konsist.api.verify.assertTrue
import org.junit.jupiter.api.Test

class ManagementServiceTest {

@Test
fun `ensure all public functions are returning Either`() {
managementServiceClass()
.functions()
.withPublicOrDefaultModifier()
.filter { excludedFunctions().contains(it.name).not() }
.assertTrue { it.returnType?.name?.startsWith(EITHER_CLASS_NAME) == true }
}

private fun managementServiceClass() =
Konsist.scopeFromProject().classes().first { it.name == MANAGEMENT_SERVICE_CLASS_NAME }

private fun excludedFunctions() = setOf(START, STOP)

companion object {
private const val MANAGEMENT_SERVICE_CLASS_NAME = "ManagementService"
private const val START = "start"
private const val STOP = "stop"
private const val EITHER_CLASS_NAME = "Either"
}
}

0 comments on commit ac826a8

Please sign in to comment.