package de.arxsilex.maptools.converter.desktop

import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNull

class PackagedWorkerResolverTest {
    @Test
    fun `resolves Windows worker next to main executable`() {
        val result = PackagedWorkerResolver.find(
            resourcesDirectory = "C:/MapTools/app/resources",
            osName = "Windows 11",
            exists = { true },
        )

        assertEquals("C:/MapTools/maptools-worker.exe", result.toString().replace('\\', '/'))
    }

    @Test
    fun `resolves Linux worker in bin directory`() {
        val result = PackagedWorkerResolver.find(
            resourcesDirectory = "/opt/maptools/lib/app/resources",
            osName = "Linux",
            exists = { true },
        )

        assertEquals("/opt/maptools/bin/maptools-worker", result.toString().replace('\\', '/'))
    }

    @Test
    fun `falls back to development command when packaged worker is missing`() {
        assertNull(PackagedWorkerResolver.find(null, "Linux") { false })
    }
}
