github.com/chalford/terraform@v0.3.7-0.20150113080010-a78c69a8c81f/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 36 for i, tc := range cases { 37 output, err := Detect(tc.Input, tc.Pwd) 38 if (err != nil) != tc.Err { 39 t.Fatalf("%d: bad err: %s", i, err) 40 } 41 if output != tc.Output { 42 t.Fatalf("%d: bad output: %s", i, output) 43 } 44 } 45 }