(t *testing.T)
| 93 | } |
| 94 | |
| 95 | func TestValidateCommand_SyntaxOnly(t *testing.T) { |
| 96 | tt := []struct { |
| 97 | path string |
| 98 | exitCode int |
| 99 | }{ |
| 100 | {path: filepath.Join(testFixture("validate"), "build.json")}, |
| 101 | {path: filepath.Join(testFixture("validate"), "build.pkr.hcl")}, |
| 102 | {path: filepath.Join(testFixture("validate"), "build_with_vars.pkr.hcl")}, |
| 103 | {path: filepath.Join(testFixture("validate-invalid"), "bad_provisioner.json")}, |
| 104 | {path: filepath.Join(testFixture("validate-invalid"), "missing_build_block.pkr.hcl")}, |
| 105 | {path: filepath.Join(testFixture("validate-invalid"), "broken.json"), exitCode: 1}, |
| 106 | {path: filepath.Join(testFixture("validate"), "null_var.json")}, |
| 107 | {path: filepath.Join(testFixture("validate"), "var_foo_with_no_default.pkr.hcl")}, |
| 108 | } |
| 109 | |
| 110 | for _, tc := range tt { |
| 111 | t.Run(tc.path, func(t *testing.T) { |
| 112 | c := &ValidateCommand{ |
| 113 | Meta: TestMetaFile(t), |
| 114 | } |
| 115 | c.CoreConfig.Version = "102.0.0" |
| 116 | tc := tc |
| 117 | args := []string{"-syntax-only", tc.path} |
| 118 | if code := c.Run(args); code != tc.exitCode { |
| 119 | fatalCommand(t, c.Meta) |
| 120 | } |
| 121 | }) |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | func TestValidateCommandOKVersion(t *testing.T) { |
| 126 | c := &ValidateCommand{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…