-
-
Notifications
You must be signed in to change notification settings - Fork 150
/
coauthors_test.go
72 lines (54 loc) · 1.89 KB
/
coauthors_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
63
64
65
66
67
68
69
70
71
72
package main
import (
"path/filepath"
"testing"
)
func TestStartDoneCoAuthors(t *testing.T) {
_, configuration := setup(t)
setWorkingDir(tempDir + "/alice")
start(configuration)
createFile(t, "file3.txt", "contentIrrelevant")
next(configuration)
setWorkingDir(tempDir + "/local")
start(configuration)
createFile(t, "file1.txt", "contentIrrelevant")
next(configuration)
setWorkingDir(tempDir + "/localother")
start(configuration)
createFile(t, "file2.txt", "contentIrrelevant")
next(configuration)
setWorkingDir(tempDir + "/alice")
start(configuration)
createFile(t, "file4.txt", "contentIrrelevant")
next(configuration)
setWorkingDir(tempDir + "/bob")
start(configuration)
createFile(t, "file5.txt", "contentIrrelevant")
next(configuration)
setWorkingDir(tempDir + "/local")
start(configuration)
done(configuration)
output := readFile(t, filepath.Join(tempDir, "local", ".git", "SQUASH_MSG"))
// don't include the person running `mob done`
assertOutputNotContains(t, &output, "Co-authored-by: local <[email protected]>")
// include everyone else in commit order after removing duplicates
assertOutputContains(t, &output, "\nCo-authored-by: bob <[email protected]>\nCo-authored-by: alice <[email protected]>\nCo-authored-by: localother <[email protected]>\n")
}
func TestCreateCommitMessage(t *testing.T) {
equals(t, `
# automatically added all co-authors from WIP commits
# add missing co-authors manually
Co-authored-by: Alice <[email protected]>
Co-authored-by: Bob <[email protected]>
`, createCommitMessage([]Author{"Alice <[email protected]>", "Bob <[email protected]>"}))
}
func TestSortByLength(t *testing.T) {
slice := []string{"aa", "b"}
sortByLength(slice)
equals(t, []string{"b", "aa"}, slice)
}
func TestRemoveDuplicateValues(t *testing.T) {
slice := []string{"aa", "b", "c", "b"}
actual := removeDuplicateValues(slice)
equals(t, []string{"aa", "b", "c"}, actual)
}