-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit_test.go
62 lines (58 loc) · 847 Bytes
/
git_test.go
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package git_json_diff
import (
"testing"
"log"
)
func TestRetrieveFileContentWithCommitId(t *testing.T) {
_, err := RetrieveFileContentWithCommitId("test.json", "HEAD")
if err != nil {
t.Errorf("failed with error: %v\n", err)
}
}
func TestCompare(t *testing.T) {
testCases := []struct{input1 string; input2 string}{
{ `{
"item0": [
{"up": 1, "down": 2}
],
"item1": [
{"up": 1, "down": 2}
]}
`,
`
{
"item1": [
{"up": 1, "down": 2}
]
}
`},
{ `{
"item0": [
{"up": 1, "down": 2}
]}
`,
`
{
"item0": [
{"up": 3, "down": 4},
{"up": 1, "down": 2}
]
}
`},
{
`{
"item1": [
{"up": 1, "down": 2}
]
}`,
``,
},
}
for _, c := range testCases {
diffStr, err := Compare(c.input1, c.input2, "ascii")
log.Println(diffStr)
if err != nil {
t.Errorf("error: %v\n", err)
}
}
}