|
|
|
|
@ -6677,3 +6677,58 @@ func TestContext2Plan_variableCustomValidationsSensitive(t *testing.T) {
|
|
|
|
|
t.Fatalf("wrong error:\ngot: %s\nwant: message containing %q", got, want)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestContext2Plan_nullOutputNoOp(t *testing.T) {
|
|
|
|
|
// this should always plan a NoOp change for the output
|
|
|
|
|
m := testModuleInline(t, map[string]string{
|
|
|
|
|
"main.tf": `
|
|
|
|
|
output "planned" {
|
|
|
|
|
value = false ? 1 : null
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
ctx := testContext2(t, &ContextOpts{
|
|
|
|
|
Config: m,
|
|
|
|
|
State: states.BuildState(func(s *states.SyncState) {
|
|
|
|
|
r := s.Module(addrs.RootModuleInstance)
|
|
|
|
|
r.SetOutputValue("planned", cty.NullVal(cty.DynamicPseudoType), false)
|
|
|
|
|
}),
|
|
|
|
|
})
|
|
|
|
|
plan, diags := ctx.Plan()
|
|
|
|
|
if diags.HasErrors() {
|
|
|
|
|
t.Fatal(diags.Err())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, c := range plan.Changes.Outputs {
|
|
|
|
|
if c.Action != plans.NoOp {
|
|
|
|
|
t.Fatalf("expected no changes, got %s for %q", c.Action, c.Addr)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestContext2Plan_createOutput(t *testing.T) {
|
|
|
|
|
// this should always plan a NoOp change for the output
|
|
|
|
|
m := testModuleInline(t, map[string]string{
|
|
|
|
|
"main.tf": `
|
|
|
|
|
output "planned" {
|
|
|
|
|
value = 1
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
ctx := testContext2(t, &ContextOpts{
|
|
|
|
|
Config: m,
|
|
|
|
|
State: states.NewState(),
|
|
|
|
|
})
|
|
|
|
|
plan, diags := ctx.Plan()
|
|
|
|
|
if diags.HasErrors() {
|
|
|
|
|
t.Fatal(diags.Err())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, c := range plan.Changes.Outputs {
|
|
|
|
|
if c.Action != plans.Create {
|
|
|
|
|
t.Fatalf("expected Create change, got %s for %q", c.Action, c.Addr)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|