package com.correx.core.transitions.graph

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNull
import org.junit.jupiter.api.Test

class BuildExpectationTest {

    @Test
    fun `toolchain command overrides flat command for matching produced kind`() {
        val commands = mapOf(
            "build" to "./gradlew assemble",
            "node.build" to "npm --prefix frontend run build",
        )

        assertEquals("npm --prefix frontend run build", BuildExpectation.PROJECT.commandFor(commands, "node"))
        assertEquals("./gradlew assemble", BuildExpectation.PROJECT.commandFor(commands, "jvm"))
    }

    @Test
    fun `flat command remains compatible when a toolchain has no override`() {
        assertEquals(
            "./gradlew check",
            BuildExpectation.TESTS.commandFor(mapOf("test" to "./gradlew check"), "jvm"),
        )
    }

    @Test
    fun `none has no command`() {
        assertNull(BuildExpectation.NONE.commandFor(mapOf("build" to "ignored"), "node"))
    }
}
