github.com/fluxrad/terraform@v0.6.4-0.20150906191316-06627ccf39fa/config/module/detect_test.go (about) 1 package module 2 3 import ( 4 "testing" 5 ) 6 7 func TestDetect(t *testing.T) { 8 cases := []struct { 9 Input string 10 Pwd string 11 Output string 12 Err bool 13 }{ 14 {"./foo", "/foo", "file:///foo/foo", false}, 15 {"git::./foo", "/foo", "git::file:///foo/foo", false}, 16 { 17 "git::github.com/hashicorp/foo", 18 "", 19 "git::https://github.com/hashicorp/foo.git", 20 false, 21 }, 22 { 23 "./foo//bar", 24 "/foo", 25 "file:///foo/foo//bar", 26 false, 27 }, 28 { 29 "git::github.com/hashicorp/foo//bar", 30 "", 31 "git::https://github.com/hashicorp/foo.git//bar", 32 false, 33 }, 34 { 35 "git::https://github.com/hashicorp/consul.git", 36 "", 37 "git::https://github.com/hashicorp/consul.git", 38 false, 39 }, 40 } 41 42 for i, tc := range cases { 43 output, err := Detect(tc.Input, tc.Pwd) 44 if (err != nil) != tc.Err { 45 t.Fatalf("%d: bad err: %s", i, err) 46 } 47 if output != tc.Output { 48 t.Fatalf("%d: bad output: %s\nexpected: %s", i, output, tc.Output) 49 } 50 } 51 }