|
|
|
|
@ -2447,3 +2447,38 @@ resource "aws_instance" "test" {
|
|
|
|
|
t.Fatal(diags.ErrWithWarnings())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestContext2Validate_deprecatedAttr(t *testing.T) {
|
|
|
|
|
p := testProvider("aws")
|
|
|
|
|
p.GetProviderSchemaResponse = getProviderSchemaResponseFromProviderSchema(&ProviderSchema{
|
|
|
|
|
ResourceTypes: map[string]*configschema.Block{
|
|
|
|
|
"aws_instance": {
|
|
|
|
|
Attributes: map[string]*configschema.Attribute{
|
|
|
|
|
"foo": {Type: cty.String, Optional: true, Deprecated: true},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
m := testModuleInline(t, map[string]string{
|
|
|
|
|
"main.tf": `
|
|
|
|
|
resource "aws_instance" "test" {
|
|
|
|
|
}
|
|
|
|
|
locals {
|
|
|
|
|
deprecated = aws_instance.test.foo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
`,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
ctx := testContext2(t, &ContextOpts{
|
|
|
|
|
Providers: map[addrs.Provider]providers.Factory{
|
|
|
|
|
addrs.NewDefaultProvider("aws"): testProviderFuncFixed(p),
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
diags := ctx.Validate(m)
|
|
|
|
|
warn := diags.ErrWithWarnings().Error()
|
|
|
|
|
if !strings.Contains(warn, `The attribute "foo" is deprecated`) {
|
|
|
|
|
t.Fatalf("expected deprecated warning, got: %q\n", warn)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|