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.
}
Exemple #2
0
func TestMultipleOutgoingChangesToTheSameFileAreAvailableInAdditions(t *testing.T) {
	cleanTestData()
	_, repo := setupOriginAndClones("data/testLocation1", "data/cloneLocation")
	git.AppendFileContent(repo.root, "a.txt", "New content.\n")
	git.AddAndcommit(repo.root, "a.txt", "added some new content")

	git.AppendFileContent(repo.root, "a.txt", "More new content.\n")
	git.AddAndcommit(repo.root, "a.txt", "added some more new content")

	assert.Len(t, repo.AllAdditions(), 1)
	assert.True(t, strings.HasSuffix(string(repo.AllAdditions()[0].Data), "New content.\nMore new content.\n"))
}
Exemple #3
0
func TestOutgoingContentOfModifiedFilesIsAvailableInChanges(t *testing.T) {
	cleanTestData()
	_, repo := setupOriginAndClones("data/testLocation1", "data/cloneLocation")
	git.AppendFileContent(repo.root, "a.txt", "New content.\n", "Spanning multiple lines, even.")
	git.AddAndcommit(repo.root, "a.txt", "added to lorem-ipsum content with my own stuff!")
	assert.Len(t, repo.AllAdditions(), 1)
	assert.True(t, strings.HasSuffix(string(repo.AllAdditions()[0].Data), "New content.\nSpanning multiple lines, even."))
}
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 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)
}
Exemple #6
0
func TestAdditionsReturnsEditsAndAdds(t *testing.T) {
	cleanTestData()
	_, repo := setupOriginAndClones("data/testLocation1", "data/cloneLocation")
	git.AppendFileContent(repo.root, "a.txt", "New content.\n", "Spanning multiple lines, even.")
	git.CreateFileWithContents(repo.root, "new.txt", "created contents")
	git.AddAndcommit(repo.root, "*", "added to lorem-ipsum content with my own stuff!")

	additions := repo.Additions("HEAD~1", "HEAD")
	assert.Len(t, additions, 2)
	assert.True(t, strings.HasSuffix(string(additions[0].Data), "New content.\nSpanning multiple lines, even."))
}