MCPcopy
hub / github.com/hashicorp/packer / TestValidateCommand_ShowLineNumForMissing

Function TestValidateCommand_ShowLineNumForMissing

command/validate_test.go:352–389  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

350}
351
352func 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
379Known: [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}

Callers

nothing calls this directly

Calls 7

RunMethod · 0.95
testFixtureFunction · 0.85
TestMetaFileFunction · 0.85
fatalCommandFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…