@@ -5,34 +5,44 @@ import (
55 "testing"
66)
77
8- func TestGetPkgType (b * testing.T ) {
8+ func TestGetPkgType (t * testing.T ) {
99 testCases := []struct {
1010 Line string
1111 LocalFlag string
1212 ExpectedResult int
1313 }{
14+ {Line : `"foo/pkg/bar"` , LocalFlag : "" , ExpectedResult : remote },
1415 {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 },
1816 {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 },
2217 {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 },
2322 {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 },
2428 {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 },
2534 {Line : `"os/signal"` , LocalFlag : "github.com/foo/bar" , ExpectedResult : standard },
2635 }
2736
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 {
3344 t .Errorf ("bad result: %d, expected: %d" , got , want )
3445 }
35- }
36- b .Run (fmt .Sprintf ("%s:%s" , tCase .LocalFlag , tCase .Line ), testFn )
46+ })
3747 }
3848}
0 commit comments