-
Notifications
You must be signed in to change notification settings - Fork 9
/
template_params_test.go
77 lines (73 loc) · 1.71 KB
/
template_params_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
73
74
75
76
77
package main
import (
"reflect"
"testing"
)
var (
inputs = []struct {
Params, RepoName string
Expected *Params
}{
{
"string",
&Params{
Types: []string{"string"},
RawTypes: []string{"string"},
},
},
{
"*string",
&Params{
Types: []string{"*string"},
RawTypes: []string{"*string"},
},
},
{
"string_int",
&Params{
Types: []string{"string", "int"},
RawTypes: []string{"string", "int"},
},
},
{
"string_io.Reader",
&Params{
Types: []string{"string", "dep1.Reader"},
RawTypes: []string{"string", "io.Reader"},
Imports: []Import{{Alias: "dep1", Path: "io"}},
},
},
{
"string_io.Reader_net/http.Client",
&Params{
Types: []string{"string", "dep1.Reader", "dep2.Client"},
RawTypes: []string{"string", "io.Reader", "net/http.Client"},
Imports: []Import{{Alias: "dep1", Path: "io"}, {Alias: "dep2", Path: "net/http"}},
},
},
{
"string_gonerics.io/d/set/string/wow.git.Set",
&Params{
Types: []string{"string", "dep1.Set"},
RawTypes: []string{"string", "gonerics.io/d/set/string/wow.git.Set"},
Imports: []Import{{Alias: "dep1", Path: "gonerics.io/d/set/string/wow.git"}},
},
},
{
"string_gonerics.io/d/set/string/wow.git.**Set",
&Params{
Types: []string{"string", "**dep1.Set"},
RawTypes: []string{"string", "gonerics.io/d/set/string/wow.git.**Set"},
Imports: []Import{{Alias: "dep1", Path: "gonerics.io/d/set/string/wow.git"}},
},
},
}
)
func TestParseParams(t *testing.T) {
for _, test := range inputs {
result := Parse(test.Param)
if !reflect.DeepEqual(test.Expected, result) {
t.Error("Failed", test.Params, test.Expected, result)
}
}
}