...
1 package model
2
3 import (
4 "fmt"
5 "testing"
6 )
7
8 func TestImpPath(t *testing.T) {
9 nonVendor := "github.com/foo/bar"
10 if nonVendor != impPath(nonVendor) {
11 t.Errorf("")
12
13 }
14 testCases := []struct {
15 input string
16 want string
17 }{
18 {"foo/bar", "foo/bar"},
19 {"vendor/foo/bar", "foo/bar"},
20 {"vendor/foo/vendor/bar", "bar"},
21 {"/vendor/foo/bar", "foo/bar"},
22 {"qux/vendor/foo/bar", "foo/bar"},
23 {"qux/vendor/foo/vendor/bar", "bar"},
24 {"govendor/foo", "govendor/foo"},
25 {"foo/govendor/bar", "foo/govendor/bar"},
26 {"vendors/foo", "vendors/foo"},
27 {"foo/vendors/bar", "foo/vendors/bar"},
28 }
29 for _, tc := range testCases {
30 t.Run(fmt.Sprintf("input %s", tc.input), func(t *testing.T) {
31 if got := impPath(tc.input); got != tc.want {
32 t.Errorf("got %s; want %s", got, tc.want)
33 }
34 })
35 }
36 }
37
View as plain text