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

Function TestValidateCommand_SyntaxOnly

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

Source from the content-addressed store, hash-verified

93}
94
95func 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
125func TestValidateCommandOKVersion(t *testing.T) {
126 c := &ValidateCommand{

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…