github.com/bhameyie/otto@v0.2.1-0.20160406174117-16052efa52ec/appfile/detect/detect_test.go (about) 1 package detect 2 3 import ( 4 "path/filepath" 5 "testing" 6 ) 7 8 func TestApp(t *testing.T) { 9 cases := []struct { 10 Dir string 11 Expected string 12 Err bool 13 Detectors []*Detector 14 }{ 15 { 16 "app-none", 17 "", 18 false, 19 []*Detector{ 20 &Detector{ 21 Type: "go", 22 File: []string{"*.go"}, 23 }, 24 }, 25 }, 26 27 { 28 "app-go", 29 "go", 30 false, 31 []*Detector{ 32 &Detector{ 33 Type: "go", 34 File: []string{"*.go"}, 35 }, 36 }, 37 }, 38 39 { 40 "app-ruby", 41 "ruby", 42 false, 43 []*Detector{ 44 &Detector{ 45 Type: "ruby", 46 File: []string{"*.rb", "Gemfile"}, 47 }, 48 }, 49 }, 50 51 { 52 "app-contents", 53 "foo", 54 false, 55 []*Detector{ 56 &Detector{ 57 Type: "foo", 58 Contents: map[string]string{ 59 "Foofile": "true", 60 }, 61 }, 62 }, 63 }, 64 } 65 66 for _, tc := range cases { 67 actual, err := App(filepath.Join("test-fixtures", tc.Dir), &Config{ 68 Detectors: tc.Detectors, 69 }) 70 if (err != nil) != tc.Err { 71 t.Fatalf("%s err: %s", tc.Dir, err) 72 } 73 74 if actual != tc.Expected { 75 t.Fatalf("%s: %s != %s", tc.Dir, actual, tc.Expected) 76 } 77 } 78 }