func TestSettingUpBaselineFilesSetsUpACommitInRepo(t *testing.T) {
	cleanTestData()
	repo := RepoLocatedAt("data/testLocation1")
	git.Init(repo.root)
	git.SetupBaselineFiles(repo.root, "a.txt", "alice/bob/b.txt")
	verifyPresenceOfGitRepoWithCommits("data/testLocation1", 1, t)
}
func TestInitializingANewRepoSetsUpFolderAndGitStructures(t *testing.T) {
	cleanTestData()
	repo := RepoLocatedAt("data/dir/sub_dir/testLocation2")
	git.Init(repo.root)
	assert.True(t, exists(repo.root), "Git Repo initialization should create the directory structure required")
	assert.True(t, isGitRepo(repo.root), "Repo root does not contain the .git folder")
}
Example #3
0
func setupOriginAndClones(originLocation, cloneLocation string) (GitRepo, GitRepo) {
	origin := RepoLocatedAt(originLocation)
	git.Init(origin.root)
	git.SetupBaselineFiles(origin.root, "a.txt", "alice/bob/b.txt")
	git.GitClone(origin.root, cloneLocation)
	return origin, RepoLocatedAt(cloneLocation)
}
func TestCloningARepoToAnotherWorks(t *testing.T) {
	cleanTestData()
	repo := RepoLocatedAt("data/testLocation1")
	git.Init(repo.root)
	git.SetupBaselineFiles(repo.root, "a.txt", "alice/bob/b.txt")
	git.GitClone(repo.root, "data/somewhereElse/testLocationClone")
	verifyPresenceOfGitRepoWithCommits("data/testLocation1", 1, t)
	verifyPresenceOfGitRepoWithCommits("data/somewhereElse/testLocationClone", 1, t)
}
func TestEarliestCommits(t *testing.T) {
	cleanTestData()
	repo := RepoLocatedAt("data/testLocation1")
	git.Init(repo.root)
	git.SetupBaselineFiles(repo.root, "a.txt")
	initialCommit := git.EarliestCommit(repo.root)
	git.AppendFileContent(repo.root, "a.txt", "\nmonkey see.\n", "monkey do.")
	git.AddAndcommit(repo.root, "a.txt", "modified content")
	assert.Equal(t, initialCommit, git.EarliestCommit(repo.root), "First commit is not expected to change on repo modifications")
}
func TestRemovingFilesInARepoWorks(t *testing.T) {
	cleanTestData()
	repo := RepoLocatedAt("data/testLocation1")
	git.Init(repo.root)
	git.SetupBaselineFiles(repo.root, "a.txt", "alice/bob/b.txt")
	git.RemoveFile(repo.root, "a.txt")
	assert.False(t, exists("data/testLocation1/a.txt"), "Unexpected. Deleted file a.txt still exists inside the repo")
	git.AddAndcommit(repo.root, "a.txt", "removed it")
	verifyPresenceOfGitRepoWithCommits("data/testLocation1", 2, t)
}
func TestLatestCommits(t *testing.T) {
	cleanTestData()
	repo := RepoLocatedAt("data/testLocation1")
	git.Init(repo.root)
	git.SetupBaselineFiles(repo.root, "a.txt")
	git.AppendFileContent(repo.root, "a.txt", "\nmonkey see.\n", "monkey do.")
	git.AddAndcommit(repo.root, "a.txt", "modified content")
	git.AppendFileContent(repo.root, "a.txt", "\nline n-1.\n", "line n.")
	git.AddAndcommit(repo.root, "a.txt", "more modified content")
	assert.NotEqual(t, git.EarliestCommit(repo.root), git.LatestCommit(repo.root)) //bad test.
}
func TestEditingFilesInARepoWorks(t *testing.T) {
	cleanTestData()
	repo := RepoLocatedAt("data/testLocation1")
	git.Init(repo.root)
	git.SetupBaselineFiles(repo.root, "a.txt", "alice/bob/b.txt")
	git.AppendFileContent(repo.root, "a.txt", "\nmonkey see.\n", "monkey do.")
	content := git.FileContents(repo.root, "a.txt")
	assert.True(t, strings.HasSuffix(string(content), "monkey see.\nmonkey do."))
	git.AddAndcommit(repo.root, "a.txt", "modified content")
	verifyPresenceOfGitRepoWithCommits("data/testLocation1", 2, t)
}
Example #9
0
func withNewTmpGitRepo(gitOp func(gitPath string)) {
	WithNewTmpDirNamed("talisman-acceptance-test", func(gitPath string) {
		git.Init(gitPath)
		gitOp(gitPath)
	})
}