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

Function TestValidateCommand_VarFiles

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

Source from the content-addressed store, hash-verified

221}
222
223func 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
260func TestValidateCommand_VarFilesWarnOnUndeclared(t *testing.T) {
261 tt := []struct {

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…