Fix upstream fixture-backed level setups

This commit is contained in:
Joe Tretter
2026-05-19 15:52:22 -05:00
parent 2091713409
commit 5db02adbe9
13 changed files with 462 additions and 95 deletions

View File

@@ -98,6 +98,52 @@ class LevelSolutionsTest {
)
}
@Test
fun upstreamFixtureBackedLevelsExposeSourceShapedSetup() {
val gitBinary = testGitBinary()
val runtimeRoot = testSandboxRoot().apply {
deleteRecursively()
mkdirs()
}
fun prepared(level: Level): RepoState = GitRepositoryRuntime(runtimeRoot, gitBinary).prepareLevel(level)
fun RepoState.fileContent(path: String): String = files.firstOrNull { it.name == path }?.content.orEmpty()
val conflict = prepared(conflictLevel())
assertEquals("master", conflict.headBranch)
assertTrue(conflict.fileContent("poem.txt").contains("Categorized shoes by color"))
assertTrue(conflict.branches.containsKey("mybranch"))
val grep = prepared(grepLevel())
assertTrue(grep.fileContent("app.rb").contains("# TODO Make site url variable."))
assertTrue(grep.fileContent("config.rb").contains("# TODO Move password to a configuration file."))
val findOldBranch = prepared(findOldBranchLevel())
assertEquals("master", findOldBranch.headBranch)
assertEquals(
setOf("blowup_sun_for_ransom", "cure_common_cold", "master", "solve_world_hunger"),
findOldBranch.branches.keys,
)
val deleteBranch = prepared(deleteBranchLevel())
assertTrue(deleteBranch.files.any { it.name == "readme" && it.tracked })
assertTrue(deleteBranch.branches.containsKey("delete_me"))
val diff = prepared(diffLevel())
assertTrue(diff.fileContent("app.rb").contains("@message = get_response('server.json')"))
val stash = prepared(stashLevel())
assertTrue(stash.fileContent("lyrics.txt").contains("Hear them loudly cry:\nHey!"))
val cherryPick = prepared(cherryPickLevel())
assertTrue(cherryPick.fileContent("README.md").contains("I'll fill in the file some time later.."))
assertTrue(cherryPick.fileContent("hardcore-math.js").contains("console.log(42 * i);"))
assertTrue(cherryPick.branches.containsKey("new-feature"))
val blame = prepared(blameLevel())
assertTrue(blame.fileContent("config.rb").contains("@password = password || \"i<3evil\""))
}
@Test
fun reportedRegressionCommandsDoNotSolveLevels() {
val statusRepo = statusLevel().setup()