github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/appfile/validate_test.go (about) 1 package appfile 2 3 import ( 4 "path/filepath" 5 "testing" 6 ) 7 8 func TestFileValidate(t *testing.T) { 9 cases := []struct { 10 File string 11 Err bool 12 }{ 13 { 14 "validate-basic", 15 false, 16 }, 17 18 { 19 "validate-no-app", 20 true, 21 }, 22 23 { 24 "validate-no-project", 25 true, 26 }, 27 28 { 29 "validate-no-infra", 30 true, 31 }, 32 33 { 34 "validate-app-no-name", 35 true, 36 }, 37 38 { 39 "validate-app-no-type", 40 true, 41 }, 42 43 { 44 "validate-project-no-name", 45 true, 46 }, 47 48 { 49 "validate-project-no-infra", 50 true, 51 }, 52 53 { 54 "validate-project-unknown-infra", 55 true, 56 }, 57 } 58 59 for _, tc := range cases { 60 f, err := ParseFile(filepath.Join("./test-fixtures", tc.File, "Appfile")) 61 if err != nil { 62 t.Fatalf("file:%s\n\n%s", tc.File, err) 63 continue 64 } 65 66 err = f.Validate() 67 if (err != nil) != tc.Err { 68 t.Fatalf("file: %s\n\n%s", tc.File, err) 69 continue 70 } 71 } 72 }