-
Notifications
You must be signed in to change notification settings - Fork 11
/
scan_test.go
50 lines (44 loc) · 998 Bytes
/
scan_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
package main
import (
"os"
"path"
"testing"
)
func TestScanGitFolders(t *testing.T) {
wd, err := os.Getwd()
if err != nil {
t.Fatalf("failed to get working directory: %v", err)
}
test := []struct {
Name string
Root string
Want []string
}{
{
Name: "3 expected repos",
Root: path.Join(wd, "test_data"),
Want: []string{path.Join(wd, "test_data", "project_1"), path.Join(wd, "test_data", "project_2"), path.Join(wd, "test_data", "project_3")},
},
{
Name: "no expected repos",
Root: path.Join(wd, ".github"),
Want: []string{},
},
}
for _, tt := range test {
t.Run(tt.Name, func(t *testing.T) {
got, err := scanGitFolders(tt.Root)
if err != nil {
t.Fatalf("failed to scan git folders: %v", err)
}
if len(got) != len(tt.Want) {
t.Fatalf("expected %d git folders, got %d", len(tt.Want), len(got))
}
for i := range got {
if got[i] != tt.Want[i] {
t.Fatalf("expected %s, got %s", tt.Want[i], got[i])
}
}
})
}
}