(t *testing.T)
| 221 | } |
| 222 | |
| 223 | func TestValidateCommand_VarFiles(t *testing.T) { |
| 224 | tt := []struct { |
| 225 | name string |
| 226 | path string |
| 227 | varfile string |
| 228 | exitCode int |
| 229 | }{ |
| 230 | {name: "with basic HCL var-file definition", |
| 231 | path: filepath.Join(testFixture(filepath.Join("validate", "var-file-tests")), "basic.pkr.hcl"), |
| 232 | varfile: filepath.Join(testFixture(filepath.Join("validate", "var-file-tests")), "basic.pkrvars.hcl"), |
| 233 | exitCode: 0, |
| 234 | }, |
| 235 | {name: "with unused variable in var-file definition", |
| 236 | path: filepath.Join(testFixture(filepath.Join("validate", "var-file-tests")), "basic.pkr.hcl"), |
| 237 | varfile: filepath.Join(testFixture(filepath.Join("validate", "var-file-tests")), "undeclared.pkrvars.hcl"), |
| 238 | exitCode: 0, |
| 239 | }, |
| 240 | {name: "with unused variable in JSON var-file definition", |
| 241 | path: filepath.Join(testFixture(filepath.Join("validate", "var-file-tests")), "basic.pkr.hcl"), |
| 242 | varfile: filepath.Join(testFixture(filepath.Join("validate", "var-file-tests")), "undeclared.json"), |
| 243 | exitCode: 0, |
| 244 | }, |
| 245 | } |
| 246 | for _, tc := range tt { |
| 247 | t.Run(tc.path, func(t *testing.T) { |
| 248 | c := &ValidateCommand{ |
| 249 | Meta: TestMetaFile(t), |
| 250 | } |
| 251 | tc := tc |
| 252 | args := []string{"-var-file", tc.varfile, tc.path} |
| 253 | if code := c.Run(args); code != tc.exitCode { |
| 254 | fatalCommand(t, c.Meta) |
| 255 | } |
| 256 | }) |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | func TestValidateCommand_VarFilesWarnOnUndeclared(t *testing.T) { |
| 261 | tt := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…