(t *testing.T)
| 350 | } |
| 351 | |
| 352 | func TestValidateCommand_ShowLineNumForMissing(t *testing.T) { |
| 353 | tt := []struct { |
| 354 | path string |
| 355 | exitCode int |
| 356 | extraArgs []string |
| 357 | }{ |
| 358 | {path: filepath.Join(testFixture("validate-invalid"), "missing_build_block.pkr.hcl"), exitCode: 1}, |
| 359 | } |
| 360 | |
| 361 | for _, tc := range tt { |
| 362 | t.Run(tc.path, func(t *testing.T) { |
| 363 | c := &ValidateCommand{ |
| 364 | Meta: TestMetaFile(t), |
| 365 | } |
| 366 | tc := tc |
| 367 | args := tc.extraArgs |
| 368 | args = append(args, tc.path) |
| 369 | if code := c.Run(args); code != tc.exitCode { |
| 370 | fatalCommand(t, c.Meta) |
| 371 | } |
| 372 | |
| 373 | stdout, stderr := GetStdoutAndErrFromTestMeta(t, c.Meta) |
| 374 | expected := fmt.Sprintf(`Error: Unknown source file.cho |
| 375 | |
| 376 | on %s line 6: |
| 377 | (source code not available) |
| 378 | |
| 379 | Known: [file.chocolate] |
| 380 | |
| 381 | |
| 382 | `, tc.path) |
| 383 | if diff := cmp.Diff(expected, stderr); diff != "" { |
| 384 | t.Errorf("Unexpected output: %s", diff) |
| 385 | } |
| 386 | t.Log(stdout) |
| 387 | }) |
| 388 | } |
| 389 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…