-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog_graph_test.go
More file actions
47 lines (43 loc) · 1.04 KB
/
log_graph_test.go
File metadata and controls
47 lines (43 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package grs
import (
"reflect"
"testing"
)
// Verifies that Scirpt.LogGraph produces a graph object
func TestLogGraph(t *testing.T) {
const TEST_ID = "TestLogGraph"
tmpdir, cleanup := MkTmpDir(t, TEST_ID)
defer cleanup()
gh := NewGitTestHelper(WithDebug(false), WithWd(tmpdir))
gh.NewRepoPair(tmpdir)
// Creates commit log with this form
// a--b---c---f
// \ /
// d---e
gh.TouchAndCommit("A.txt", "A")
gh.RunGit("tag", "Tag_A")
gh.TouchAndCommit("B.txt", "B")
gh.RunGit("tag", "Tag_B")
gh.TouchAndCommit("C.txt", "C")
gh.RunGit("checkout", "-b", "source_2", "Tag_B")
gh.TouchAndCommit("D.txt", "D")
gh.TouchAndCommit("E.txt", "E")
gh.RunGit("checkout", "master")
gh.RunGit("merge", "source_2", "-m", "F")
expected := LogGraph(map[string][]string{
"F": {"C", "E"},
"E": {"D"},
"D": {"B"},
"C": {"B"},
"B": {"A"},
"A": {"init"},
"init": {},
})
lg, err := gh.LogGraph()
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(expected, lg) {
t.Fatalf("unexpected commit graph: %s\n", lg)
}
}