mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
terraform: test the increase from one case
This commit is contained in:
parent
2389251c38
commit
11d073f7d4
@ -829,6 +829,64 @@ func TestContext2Plan_countIncreaseFromOne(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/PeoplePerHour/terraform/pull/11
|
||||
//
|
||||
// This tests a case where both a "resource" and "resource.0" are in
|
||||
// the state file, which apparently is a reasonable backwards compatibility
|
||||
// concern found in the above 3rd party repo.
|
||||
func TestContext2Plan_countIncreaseFromOneCorrupted(t *testing.T) {
|
||||
m := testModule(t, "plan-count-inc")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
s := &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
Path: rootModulePath,
|
||||
Resources: map[string]*ResourceState{
|
||||
"aws_instance.foo": &ResourceState{
|
||||
Type: "aws_instance",
|
||||
Primary: &InstanceState{
|
||||
ID: "bar",
|
||||
Attributes: map[string]string{
|
||||
"foo": "foo",
|
||||
"type": "aws_instance",
|
||||
},
|
||||
},
|
||||
},
|
||||
"aws_instance.foo.0": &ResourceState{
|
||||
Type: "aws_instance",
|
||||
Primary: &InstanceState{
|
||||
ID: "bar",
|
||||
Attributes: map[string]string{
|
||||
"foo": "foo",
|
||||
"type": "aws_instance",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
State: s,
|
||||
})
|
||||
|
||||
plan, err := ctx.Plan(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(plan.String())
|
||||
expected := strings.TrimSpace(testTerraformPlanCountIncreaseFromOneCorruptedStr)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad:\n%s", actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContext2Plan_destroy(t *testing.T) {
|
||||
m := testModule(t, "plan-destroy")
|
||||
p := testProvider("aws")
|
||||
|
@ -829,6 +829,32 @@ aws_instance.foo.0:
|
||||
type = aws_instance
|
||||
`
|
||||
|
||||
const testTerraformPlanCountIncreaseFromOneCorruptedStr = `
|
||||
DIFF:
|
||||
|
||||
CREATE: aws_instance.bar
|
||||
foo: "" => "bar"
|
||||
type: "" => "aws_instance"
|
||||
DESTROY: aws_instance.foo
|
||||
CREATE: aws_instance.foo.1
|
||||
foo: "" => "foo"
|
||||
type: "" => "aws_instance"
|
||||
CREATE: aws_instance.foo.2
|
||||
foo: "" => "foo"
|
||||
type: "" => "aws_instance"
|
||||
|
||||
STATE:
|
||||
|
||||
aws_instance.foo:
|
||||
ID = bar
|
||||
foo = foo
|
||||
type = aws_instance
|
||||
aws_instance.foo.0:
|
||||
ID = bar
|
||||
foo = foo
|
||||
type = aws_instance
|
||||
`
|
||||
|
||||
const testTerraformPlanDestroyStr = `
|
||||
DIFF:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user