package solutions.tretter.githugandroid

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class GitRepositoryRuntimeInstrumentedTest {
    @Test
    fun nativeGitRuntimeCompletesInitLevelOnDevice() {
        val context = InstrumentationRegistry.getInstrumentation().targetContext
        val runtime = GitRepositoryRuntime(context)
        val level = initLevel()

        assertTrue(runtime.unavailableMessage(), runtime.isNativeGitAvailable())

        val repo = runtime.prepareLevel(level)
        val (updatedRepo, _) = runtime.execute(level, repo, "git init")

        assertTrue(updatedRepo.initialized)
        assertTrue(level.validator(updatedRepo, "git init"))
    }
}
