-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathgenerator_test.go
More file actions
64 lines (59 loc) · 1.52 KB
/
generator_test.go
File metadata and controls
64 lines (59 loc) · 1.52 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package generators
import (
"testing"
"github.com/meshery/meshkit/generators/github"
)
func TestNewGeneratorWithOptions(t *testing.T) {
tests := []struct {
name string
registrant string
url string
packageName string
opts GeneratorOptions
wantRec bool
wantDepth int
}{
{
name: "Github Recursive",
registrant: "github",
url: "https://github.com/owner/repo",
packageName: "test",
opts: GeneratorOptions{
Recursive: true,
MaxDepth: 5,
},
wantRec: true,
wantDepth: 5,
},
{
name: "Github Default",
registrant: "github",
url: "https://github.com/owner/repo",
packageName: "test",
opts: GeneratorOptions{
Recursive: false,
MaxDepth: 0,
},
wantRec: false,
wantDepth: 0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
pm, err := NewGeneratorWithOptions(tt.registrant, tt.url, tt.packageName, tt.opts)
if err != nil {
t.Fatalf("NewGeneratorWithOptions() error = %v", err)
}
if ghpm, ok := pm.(github.GitHubPackageManager); ok {
if ghpm.Recursive != tt.wantRec {
t.Errorf("NewGeneratorWithOptions() Recursive = %v, want %v", ghpm.Recursive, tt.wantRec)
}
if ghpm.MaxDepth != tt.wantDepth {
t.Errorf("NewGeneratorWithOptions() MaxDepth = %v, want %v", ghpm.MaxDepth, tt.wantDepth)
}
} else {
t.Errorf("NewGeneratorWithOptions() returned unexpected type")
}
})
}
}