MCPcopy Index your code
hub / github.com/hashicorp/packer / TestValidateCommand_SkipDatasourceExecution

Function TestValidateCommand_SkipDatasourceExecution

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

Source from the content-addressed store, hash-verified

70}
71
72func TestValidateCommand_SkipDatasourceExecution(t *testing.T) {
73 datasourceMock := &packersdk.MockDatasource{}
74 meta := TestMetaFile(t)
75 meta.CoreConfig.Components.PluginConfig.DataSources = packer.MapOfDatasource{
76 "mock": func() (packersdk.Datasource, error) {
77 return datasourceMock, nil
78 },
79 }
80 c := &ValidateCommand{
81 Meta: meta,
82 }
83 args := []string{filepath.Join(testFixture("validate"), "datasource.pkr.hcl")}
84 if code := c.Run(args); code != 0 {
85 fatalCommand(t, c.Meta)
86 }
87 if datasourceMock.ExecuteCalled {
88 t.Fatalf("Datasource should not be executed on validation")
89 }
90 if !datasourceMock.OutputSpecCalled {
91 t.Fatalf("Datasource OutPutSpec should be called on validation")
92 }
93}
94
95func TestValidateCommand_SyntaxOnly(t *testing.T) {
96 tt := []struct {

Callers

nothing calls this directly

Calls 4

RunMethod · 0.95
TestMetaFileFunction · 0.85
testFixtureFunction · 0.85
fatalCommandFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…