fixup last tests that need correct state

This commit is contained in:
James Bardin 2020-09-11 11:42:05 -04:00
parent d19f440d81
commit 1fa3503acd
4 changed files with 24 additions and 8 deletions

View File

@ -9861,6 +9861,22 @@ func TestContext2Apply_taintedDestroyFailure(t *testing.T) {
return testApplyFn(info, s, d)
}
p.GetSchemaReturn = &ProviderSchema{
ResourceTypes: map[string]*configschema.Block{
"test_instance": {
Attributes: map[string]*configschema.Attribute{
"id": {
Type: cty.String,
Computed: true,
},
"foo": {
Type: cty.String,
Optional: true,
},
},
},
},
}
state := states.NewState()
root := state.EnsureModule(addrs.RootModuleInstance)
@ -9981,7 +9997,7 @@ func TestContext2Apply_taintedDestroyFailure(t *testing.T) {
t.Fatal("test_instance.c should have no deposed instances")
}
if string(c.Current.AttrsJSON) != `{"id":"c","foo":"old"}` {
if string(c.Current.AttrsJSON) != `{"foo":"old","id":"c"}` {
t.Fatalf("unexpected attrs for c: %q\n", c.Current.AttrsJSON)
}
}

View File

@ -2829,7 +2829,7 @@ func TestContext2Plan_countDecreaseToOne(t *testing.T) {
}
}
expectedState := `aws_instance.foo.0:
expectedState := `aws_instance.foo:
ID = bar
provider = provider["registry.terraform.io/hashicorp/aws"]
foo = foo
@ -4068,7 +4068,7 @@ func TestContext2Plan_taintDestroyInterpolatedCountRace(t *testing.T) {
Providers: map[addrs.Provider]providers.Factory{
addrs.NewDefaultProvider("aws"): testProviderFuncFixed(p),
},
State: state,
State: state.DeepCopy(),
})
plan, diags := ctx.Plan()
@ -4092,7 +4092,7 @@ func TestContext2Plan_taintDestroyInterpolatedCountRace(t *testing.T) {
switch i := ric.Addr.String(); i {
case "aws_instance.foo[0]":
if res.Action != plans.DeleteThenCreate {
t.Fatalf("resource %s should be replaced", i)
t.Fatalf("resource %s should be replaced, not %s", i, res.Action)
}
checkVals(t, objectVal(t, schema, map[string]cty.Value{
"id": cty.StringVal("bar"),

View File

@ -1,9 +1,9 @@
variable "vpc_id" {}
resource "aws_instance" "child" {
vpc_id = "${var.vpc_id}"
vpc_id = var.vpc_id
}
output "modout" {
value = "${aws_instance.child.id}"
value = aws_instance.child.id
}

View File

@ -2,9 +2,9 @@ resource "aws_instance" "vpc" { }
module "child" {
source = "./child"
vpc_id = "${aws_instance.vpc.id}"
vpc_id = aws_instance.vpc.id
}
output "out" {
value = "${module.child.modout}"
value = module.child.modout
}