github.com/hori-ryota/glide@v0.0.0-20160621143827-dc7ca2fac035/util/normalizename_test.go (about) 1 package util 2 3 import ( 4 "testing" 5 ) 6 7 func TestNormalizeName(t *testing.T) { 8 packages := []struct { 9 input string 10 root string 11 extra string 12 }{ 13 { 14 input: "github.com/Masterminds/cookoo/web/io/foo", 15 root: "github.com/Masterminds/cookoo", 16 extra: "web/io/foo", 17 }, 18 { 19 input: `github.com\Masterminds\cookoo\web\io\foo`, 20 root: "github.com/Masterminds/cookoo", 21 extra: "web/io/foo", 22 }, 23 { 24 input: "golang.org/x/crypto/ssh", 25 root: "golang.org/x/crypto", 26 extra: "ssh", 27 }, 28 { 29 input: "incomplete/example", 30 root: "incomplete/example", 31 extra: "", 32 }, 33 { 34 input: "net", 35 root: "net", 36 extra: "", 37 }, 38 } 39 for _, test := range packages { 40 root, extra := NormalizeName(test.input) 41 if root != test.root { 42 t.Errorf("%s: Expected root '%s', got '%s'", test.input, test.root, root) 43 } 44 if extra != test.extra { 45 t.Errorf("%s: Expected extra '%s', got '%s'", test.input, test.extra, extra) 46 } 47 } 48 }