command: validate configuration, test for it

pull/12/head
Mitchell Hashimoto 12 years ago
parent 78e056770c
commit d23733263f

@ -48,6 +48,24 @@ func TestApply(t *testing.T) {
}
}
func TestApply_configInvalid(t *testing.T) {
p := testProvider()
ui := new(cli.MockUi)
c := &ApplyCommand{
TFConfig: testTFConfig(p),
Ui: ui,
}
args := []string{
"-init",
testTempFile(t),
testFixturePath("apply-config-invalid"),
}
if code := c.Run(args); code != 1 {
t.Fatalf("bad: \n%s", ui.OutputWriter.String())
}
}
func TestApply_plan(t *testing.T) {
planPath := testPlanFile(t, new(terraform.Plan))
statePath := testTempFile(t)

@ -55,6 +55,9 @@ func PlanArg(
if err != nil {
return nil, fmt.Errorf("Error loading config: %s", err)
}
if err := config.Validate(); err != nil {
return nil, fmt.Errorf("Error validating config: %s", err)
}
plan, err := tf.Plan(&terraform.PlanOpts{
Config: config,

@ -0,0 +1,3 @@
resource "test_instance" "foo" {
ami = "${var.nope}"
}
Loading…
Cancel
Save