@@ -5,34 +5,44 @@ import (
5
5
"testing"
6
6
)
7
7
8
- func TestGetPkgType (b * testing.T ) {
8
+ func TestGetPkgType (t * testing.T ) {
9
9
testCases := []struct {
10
10
Line string
11
11
LocalFlag string
12
12
ExpectedResult int
13
13
}{
14
+ {Line : `"foo/pkg/bar"` , LocalFlag : "" , ExpectedResult : remote },
14
15
{Line : `"foo/pkg/bar"` , LocalFlag : "foo" , ExpectedResult : local },
15
- {Line : `"github.com/foo/bar"` , LocalFlag : "foo" , ExpectedResult : remote },
16
- {Line : `"context"` , LocalFlag : "foo" , ExpectedResult : standard },
17
- {Line : `"os/signal"` , LocalFlag : "foo" , ExpectedResult : standard },
18
16
{Line : `"foo/pkg/bar"` , LocalFlag : "bar" , ExpectedResult : remote },
19
- {Line : `"github.com/foo/bar"` , LocalFlag : "bar" , ExpectedResult : remote },
20
- {Line : `"context"` , LocalFlag : "bar" , ExpectedResult : standard },
21
- {Line : `"os/signal"` , LocalFlag : "bar" , ExpectedResult : standard },
22
17
{Line : `"foo/pkg/bar"` , LocalFlag : "github.com/foo/bar" , ExpectedResult : remote },
18
+
19
+ {Line : `"github.com/foo/bar"` , LocalFlag : "" , ExpectedResult : remote },
20
+ {Line : `"github.com/foo/bar"` , LocalFlag : "foo" , ExpectedResult : remote },
21
+ {Line : `"github.com/foo/bar"` , LocalFlag : "bar" , ExpectedResult : remote },
23
22
{Line : `"github.com/foo/bar"` , LocalFlag : "github.com/foo/bar" , ExpectedResult : local },
23
+
24
+ {Line : `"context"` , LocalFlag : "" , ExpectedResult : standard },
25
+ {Line : `"context"` , LocalFlag : "context" , ExpectedResult : local },
26
+ {Line : `"context"` , LocalFlag : "foo" , ExpectedResult : standard },
27
+ {Line : `"context"` , LocalFlag : "bar" , ExpectedResult : standard },
24
28
{Line : `"context"` , LocalFlag : "github.com/foo/bar" , ExpectedResult : standard },
29
+
30
+ {Line : `"os/signal"` , LocalFlag : "" , ExpectedResult : standard },
31
+ {Line : `"os/signal"` , LocalFlag : "os/signal" , ExpectedResult : local },
32
+ {Line : `"os/signal"` , LocalFlag : "foo" , ExpectedResult : standard },
33
+ {Line : `"os/signal"` , LocalFlag : "bar" , ExpectedResult : standard },
25
34
{Line : `"os/signal"` , LocalFlag : "github.com/foo/bar" , ExpectedResult : standard },
26
35
}
27
36
28
- for _ , _tCase := range testCases {
29
- tCase := _tCase
30
- testFn := func (t * testing.T ) {
31
- result := getPkgType (tCase .Line , tCase .LocalFlag )
32
- if got , want := result , tCase .ExpectedResult ; got != want {
37
+ for _ , tc := range testCases {
38
+ tc := tc
39
+ t .Run (fmt .Sprintf ("%s:%s" , tc .Line , tc .LocalFlag ), func (t * testing.T ) {
40
+ t .Parallel ()
41
+
42
+ result := getPkgType (tc .Line , tc .LocalFlag )
43
+ if got , want := result , tc .ExpectedResult ; got != want {
33
44
t .Errorf ("bad result: %d, expected: %d" , got , want )
34
45
}
35
- }
36
- b .Run (fmt .Sprintf ("%s:%s" , tCase .LocalFlag , tCase .Line ), testFn )
46
+ })
37
47
}
38
48
}
0 commit comments