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