Fix upstream fixture-backed level setups
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user