mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
adding context test for module multi-vars
This commit is contained in:
parent
4b3bf76406
commit
60022978a6
@ -2978,6 +2978,28 @@ func TestContextPlan_moduleInputFromVar(t *testing.T) {
|
||||
t.Fatalf("bad:\n%s", actual)
|
||||
}
|
||||
}
|
||||
func TestContextPlan_moduleMultiVar(t *testing.T) {
|
||||
m := testModule(t, "plan-module-multi-var")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
})
|
||||
|
||||
plan, err := ctx.Plan(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(plan.String())
|
||||
expected := strings.TrimSpace(testTerraformPlanModuleMultiVarStr)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad:\n%s", actual)
|
||||
}
|
||||
}
|
||||
func TestContextPlan_moduleOrphans(t *testing.T) {
|
||||
m := testModule(t, "plan-modules-remove")
|
||||
p := testProvider("aws")
|
||||
|
@ -841,6 +841,25 @@ STATE:
|
||||
<no state>
|
||||
`
|
||||
|
||||
const testTerraformPlanModuleMultiVarStr = `
|
||||
DIFF:
|
||||
|
||||
module.child:
|
||||
CREATE: aws_instance.bar.0
|
||||
baz: "" => "baz"
|
||||
type: "" => "aws_instance"
|
||||
CREATE: aws_instance.bar.1
|
||||
baz: "" => "baz"
|
||||
type: "" => "aws_instance"
|
||||
CREATE: aws_instance.foo
|
||||
foo: "" => "baz,baz"
|
||||
type: "" => "aws_instance"
|
||||
|
||||
STATE:
|
||||
|
||||
<no state>
|
||||
`
|
||||
|
||||
const testTerraformPlanModuleOrphansStr = `
|
||||
DIFF:
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
resource "aws_instance" "bar" {
|
||||
baz = "baz"
|
||||
count = 2
|
||||
}
|
||||
|
||||
resource "aws_instance" "foo" {
|
||||
foo = "${join(",",aws_instance.bar.*.baz)}"
|
||||
}
|
4
terraform/test-fixtures/plan-module-multi-var/main.tf
Normal file
4
terraform/test-fixtures/plan-module-multi-var/main.tf
Normal file
@ -0,0 +1,4 @@
|
||||
module "child" {
|
||||
source = "./child"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user