Auto-commit after successful build: update app gameplay/UI, improve build setup
Changed files:\napp/build.gradle.kts app/src/main/java/solutions/tretter/githugandroid/GameModels.kt app/src/main/java/solutions/tretter/githugandroid/GitHelpCommands.kt app/src/main/java/solutions/tretter/githugandroid/GitHugApp.kt app/src/main/java/solutions/tretter/githugandroid/GitRuntime.kt app/src/main/java/solutions/tretter/githugandroid/Visual.kt app/src/main/java/solutions/tretter/githugandroid/levels/AdvancedLevels.kt app/src/main/java/solutions/tretter/githugandroid/levels/LevelCatalog.kt app/src/test/java/solutions/tretter/githugandroid/GitHelpCommandsTest.kt app/src/test/java/solutions/tretter/githugandroid/GitSandboxEngineTest.kt
This commit is contained in:
@@ -14,8 +14,19 @@ class GitHelpCommandsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun ignoresNonHelpCommands() {
|
||||
assertNull(parseGitHelpInvocation("git tag -h"))
|
||||
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
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package solutions.tretter.githugandroid
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class GitSandboxEngineTest {
|
||||
@Test
|
||||
fun statusShowsDeletedTrackedFiles() {
|
||||
val repo = RepoState(
|
||||
initialized = true,
|
||||
files = listOf(GitFile("deleteme.rb", tracked = true, deleted = true)),
|
||||
commits = listOf(CommitNode("0000001", "Added a temp file")),
|
||||
branches = mapOf("master" to 1),
|
||||
)
|
||||
|
||||
val (_, output) = GitSandboxEngine.execute(repo, "git status")
|
||||
|
||||
assertTrue(output.any { it.contains("deleted:") && it.contains("deleteme.rb") })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun gitRmRemovesDeletedTrackedFileFromIndex() {
|
||||
val repo = RepoState(
|
||||
initialized = true,
|
||||
files = listOf(GitFile("deleteme.rb", tracked = true, deleted = true)),
|
||||
commits = listOf(CommitNode("0000001", "Added a temp file")),
|
||||
branches = mapOf("master" to 1),
|
||||
)
|
||||
|
||||
val (updatedRepo, _) = GitSandboxEngine.execute(repo, "git rm deleteme.rb")
|
||||
|
||||
assertFalse(updatedRepo.files.any { it.name == "deleteme.rb" })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun gitMvExpandsWildcardSourcesIntoDestinationDirectory() {
|
||||
val repo = RepoState(
|
||||
initialized = true,
|
||||
files = listOf(
|
||||
GitFile("about.html", tracked = true),
|
||||
GitFile("contact.html", tracked = true),
|
||||
GitFile("index.html", tracked = true),
|
||||
GitFile("README", tracked = true),
|
||||
),
|
||||
branches = mapOf("master" to 1),
|
||||
)
|
||||
|
||||
val (updatedRepo, _) = GitSandboxEngine.execute(repo, "git mv *.html src")
|
||||
|
||||
assertTrue(updatedRepo.files.any { it.name == "src/about.html" })
|
||||
assertTrue(updatedRepo.files.any { it.name == "src/contact.html" })
|
||||
assertTrue(updatedRepo.files.any { it.name == "src/index.html" })
|
||||
assertTrue(updatedRepo.files.any { it.name == "README" })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun commitHashAnswerAcceptsFullHashThatStartsWithDisplayedShortHash() {
|
||||
val repo = RepoState(
|
||||
initialized = true,
|
||||
commits = listOf(CommitNode("abc1234", "Latest commit")),
|
||||
branches = mapOf("master" to 1),
|
||||
)
|
||||
|
||||
assertTrue(commitHashAnswer("0000001")(repo, "abc1234fedcba9876543210fedcba9876543210"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user