Files
Githug-Android/app/src/test/java/solutions/tretter/githugandroid/GitHelpCommandsTest.kt
Joe Tretter 02a23694c3 Fix level setup, reword flow, and catalog scope
- create and enter the level's declared starting directory
- inspect Git state from the repository containing the active directory
- start the init level in /sandbox/git_hug and cover it with a runtime test
- apply edited reword subjects as commit messages in the in-app rebase editor
- cover rename_commit with a native interactive rebase regression test
- remove the upstream contribute call to action from the playable level catalog
- update level parity documentation
2026-06-08 14:21:21 -05:00

66 lines
1.8 KiB
Kotlin

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() {
assertNull(parseGitHelpInvocation("git tag -h"))
}
@Test
fun parsesGitGlobalShortHelpCommand() {
val invocation = parseGitHelpInvocation("git --help tag")
assertEquals("tag", invocation?.topic)
assertEquals("git --help tag", invocation?.command)
}
@Test
fun leavesGitHelpListingOptionsForNativeGit() {
assertNull(parseGitHelpInvocation("git help -a"))
assertNull(parseGitHelpInvocation("git help --all"))
assertNull(parseGitHelpInvocation("git help -g"))
assertNull(parseGitHelpInvocation("git help --guides"))
}
@Test
fun parsesManGitCommand() {
val invocation = parseGitHelpInvocation("man git-cherry-pick")
assertEquals("cherry-pick", invocation?.topic)
assertEquals("man git-cherry-pick", invocation?.command)
}
@Test
fun parsesSplitManGitCommand() {
val invocation = parseGitHelpInvocation("man git cherry-pick")
assertEquals("cherry-pick", invocation?.topic)
assertEquals("man git cherry-pick", invocation?.command)
}
@Test
fun parsesMainGitManpageCommand() {
val invocation = parseGitHelpInvocation("man git")
assertEquals("git", invocation?.topic)
assertEquals("man git", invocation?.command)
}
@Test
fun rejectsUnsafeHelpTopic() {
assertNull(parseGitHelpInvocation("git help ../config"))
}
}