-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgit_test.go
52 lines (48 loc) · 1.36 KB
/
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
package rrh
import (
"testing"
)
func TestNewStatusOptions(t *testing.T) {
var opts = NewStatusOption()
if opts.BranchStatus != false && opts.RemoteStatus != false {
t.Errorf("default values of StatusOption did not match.")
}
}
func TestGenerateMessage(t *testing.T) {
var testcases = []struct {
stagingFlag bool
changesFlag bool
wontMessage string
}{
{true, true, "Changes in staging"},
{false, true, "Changes in workspace"},
{true, false, "No changes"},
{false, false, "No changes"},
}
for _, tc := range testcases {
var message = generateMessage(tc.stagingFlag, tc.changesFlag)
if message != tc.wontMessage {
t.Errorf("generateMessage(%v, %v) did not match, wont: %s, got: %s", tc.stagingFlag, tc.changesFlag, tc.wontMessage, message)
}
}
}
func TestFindRemotes(t *testing.T) {
var testdata = []struct {
path string
errorFlag bool
count int
}{
{"testdata/dummygit", true, 0},
{"testdata/helloworld", false, 1},
{"testdata/fibonacci", false, 1},
}
for _, td := range testdata {
var remotes, err = FindRemotes(td.path)
if (err == nil) == td.errorFlag {
t.Errorf("%s: error flag did not match, wont: %v, got: %v, %v", td.path, td.errorFlag, !td.errorFlag, err)
}
if err != nil && td.count != len(remotes) {
t.Errorf("%s: remote count did not match, wont: %d, got: %d", td.path, td.count, len(remotes))
}
}
}