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

Function TestValidateCommandBadVersion

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

Source from the content-addressed store, hash-verified

138}
139
140func TestValidateCommandBadVersion(t *testing.T) {
141 c := &ValidateCommand{
142 Meta: TestMetaFile(t),
143 }
144 args := []string{
145 filepath.Join(testFixture("validate"), "template.json"),
146 }
147
148 // This should fail with an invalid configuration version
149 c.CoreConfig.Version = "100.0.0"
150 if code := c.Run(args); code != 1 {
151 t.Errorf("Expected exit code 1")
152 }
153
154 stdout, stderr := GetStdoutAndErrFromTestMeta(t, c.Meta)
155 expected := `Error:
156
157This template requires Packer version 101.0.0 or higher; using 100.0.0
158
159
160`
161
162 if diff := cmp.Diff(expected, stderr); diff != "" {
163 t.Errorf("Unexpected output: %s", diff)
164 }
165 t.Log(stdout)
166}
167
168func TestValidateCommandExcept(t *testing.T) {
169 tt := []struct {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…