-
Notifications
You must be signed in to change notification settings - Fork 6
/
public_test.go
72 lines (70 loc) · 1.04 KB
/
public_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 modver
import (
"fmt"
"testing"
)
func TestIsPublic(t *testing.T) {
cases := []struct {
inp string
want bool
}{{
inp: "main",
want: false,
}, {
inp: "internal",
want: false,
}, {
inp: "mainx",
want: true,
}, {
inp: "internalx",
want: true,
}, {
inp: "foo/main",
want: false,
}, {
inp: "main/foo",
want: true,
}, {
inp: "foo/mainx",
want: true,
}, {
inp: "mainx/foo",
want: true,
}, {
inp: "foo/internal",
want: false,
}, {
inp: "internal/foo",
want: false,
}, {
inp: "foo/internal/bar",
want: false,
}, {
inp: "foo/internalx",
want: true,
}, {
inp: "internalx/foo",
want: true,
}, {
inp: "foo/xinternal/bar",
want: true,
}, {
inp: "foo/xinternal",
want: true,
}, {
inp: "xinternal/foo",
want: true,
}, {
inp: "foo/xinternal/bar",
want: true,
}}
for i, tc := range cases {
t.Run(fmt.Sprintf("case_%02d", i+1), func(t *testing.T) {
got := isPublic(tc.inp)
if got != tc.want {
t.Errorf("got %v, want %v", got, tc.want)
}
})
}
}