github.com/weiwenhao/getter@v1.30.1/detect_gitlab_test.go (about) 1 package getter 2 3 import ( 4 "testing" 5 ) 6 7 func TestGitLabDetector(t *testing.T) { 8 cases := []struct { 9 Input string 10 Output string 11 }{ 12 // HTTP 13 {"gitlab.com/hashicorp/foo", "git::https://gitlab.com/hashicorp/foo.git"}, 14 {"gitlab.com/hashicorp/foo.git", "git::https://gitlab.com/hashicorp/foo.git"}, 15 { 16 "gitlab.com/hashicorp/foo/bar", 17 "git::https://gitlab.com/hashicorp/foo.git//bar", 18 }, 19 { 20 "gitlab.com/hashicorp/foo?foo=bar", 21 "git::https://gitlab.com/hashicorp/foo.git?foo=bar", 22 }, 23 { 24 "gitlab.com/hashicorp/foo.git?foo=bar", 25 "git::https://gitlab.com/hashicorp/foo.git?foo=bar", 26 }, 27 } 28 29 pwd := "/pwd" 30 f := new(GitLabDetector) 31 for i, tc := range cases { 32 output, ok, err := f.Detect(tc.Input, pwd) 33 if err != nil { 34 t.Fatalf("err: %s", err) 35 } 36 if !ok { 37 t.Fatal("not ok") 38 } 39 40 if output != tc.Output { 41 t.Fatalf("%d: bad: %#v", i, output) 42 } 43 } 44 }