MCPcopy Create free account
hub / github.com/libgit2/git2go / TestRevert

Function TestRevert

revert_test.go:11–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestRevert(t *testing.T) {
12 t.Parallel()
13 repo := createTestRepo(t)
14 defer cleanupTestRepo(t, repo)
15
16 seedTestRepo(t, repo)
17 commitID, _ := updateReadme(t, repo, content)
18
19 commit, err := repo.LookupCommit(commitID)
20 checkFatal(t, err)
21
22 revertOptions, err := DefaultRevertOptions()
23 checkFatal(t, err)
24
25 err = repo.Revert(commit, &revertOptions)
26 checkFatal(t, err)
27
28 actualReadmeContents := readReadme(t, repo)
29
30 if actualReadmeContents != expectedRevertedReadmeContents {
31 t.Fatalf(`README has incorrect contents after revert. Expected: "%v", Actual: "%v"`,
32 expectedRevertedReadmeContents, actualReadmeContents)
33 }
34
35 state := repo.State()
36 if state != RepositoryStateRevert {
37 t.Fatalf("Incorrect repository state. Expected: %v, Actual: %v", RepositoryStateRevert, state)
38 }
39
40 err = repo.StateCleanup()
41 checkFatal(t, err)
42
43 state = repo.State()
44 if state != RepositoryStateNone {
45 t.Fatalf("Incorrect repository state. Expected: %v, Actual: %v", RepositoryStateNone, state)
46 }
47}
48
49func TestRevertCommit(t *testing.T) {
50 t.Parallel()

Callers

nothing calls this directly

Calls 11

createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
seedTestRepoFunction · 0.85
updateReadmeFunction · 0.85
checkFatalFunction · 0.85
DefaultRevertOptionsFunction · 0.85
readReadmeFunction · 0.85
LookupCommitMethod · 0.80
RevertMethod · 0.80
StateMethod · 0.80
StateCleanupMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…