core: Fix TestContext2Apply_vars

Since this test sets its own special schema for aws_instance, its expected
output must now be adjusted to only expect values that conform to that
schema. The extraneous attributes like "type" which testDiffFn produces
are no longer visible unless declared in schema.

We also need to now declare "id" as a computed attribute in order for our
state stringer shim to properly populate the formerly-special "ID".
This commit is contained in:
Martin Atkins 2018-09-17 15:58:49 -07:00
parent d574a86d41
commit c89f1fea63
3 changed files with 5 additions and 6 deletions

View File

@ -8263,10 +8263,10 @@ func TestContext2Apply_vars(t *testing.T) {
t.Fatalf("err: %s", diags.Err())
}
actual := strings.TrimSpace(state.String())
expected := strings.TrimSpace(testTerraformApplyVarsStr)
if actual != expected {
t.Errorf("wrong result\n\ngot:\n%s\n\nwant:\n%s", actual, expected)
got := strings.TrimSpace(state.String())
want := strings.TrimSpace(testTerraformApplyVarsStr)
if got != want {
t.Errorf("wrong result\n\ngot:\n%s\n\nwant:\n%s", got, want)
}
}

View File

@ -38,6 +38,7 @@ func contextFixtureApplyVars(t *testing.T) *contextTestFixture {
c := testModule(t, "apply-vars")
p := mockProviderWithResourceTypeSchema("aws_instance", &configschema.Block{
Attributes: map[string]*configschema.Attribute{
"id": {Type: cty.String, Computed: true},
"foo": {Type: cty.String, Optional: true},
"bar": {Type: cty.String, Optional: true},
"baz": {Type: cty.String, Optional: true},

View File

@ -1017,7 +1017,6 @@ aws_instance.bar:
bar = override
baz = override
foo = us-east-1
type = aws_instance
aws_instance.foo:
ID = foo
provider = provider.aws
@ -1029,7 +1028,6 @@ aws_instance.foo:
map.Foo = Bar
map.Hello = World
num = 2
type = aws_instance
`
const testTerraformApplyVarsEnvStr = `