package solutions.tretter.githugandroid

import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test

class GitHelpCommandsTest {
    @Test
    fun parsesGitHelpCommand() {
        val invocation = parseGitHelpInvocation("git help tag")

        assertEquals("tag", invocation?.topic)
        assertEquals("git help tag", invocation?.command)
    }

    @Test
    fun parsesGitSubcommandShortHelpCommand() {
        val invocation = parseGitHelpInvocation("git tag -h")

        assertEquals("tag", invocation?.topic)
        assertEquals("git tag -h", invocation?.command)
    }

    @Test
    fun parsesGitGlobalShortHelpCommand() {
        val invocation = parseGitHelpInvocation("git -h tag")

        assertEquals("tag", invocation?.topic)
        assertEquals("git -h tag", invocation?.command)
    }

    @Test
    fun rejectsUnsafeHelpTopic() {
        assertNull(parseGitHelpInvocation("git help ../config"))
    }
}
