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:
Joe Tretter
2026-05-05 19:27:33 -05:00
parent 6200fdc912
commit 16d7809150
10 changed files with 322 additions and 46 deletions

View File

@@ -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"))
}
}