mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-13 09:32:24 -06:00
terraform: test for variables in provider configs
This commit is contained in:
parent
0a5e06d62c
commit
914cb1d44c
@ -3782,6 +3782,36 @@ func TestContextPlan_multiple_taint(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextPlan_provider(t *testing.T) {
|
||||
m := testModule(t, "plan-provider")
|
||||
p := testProvider("aws")
|
||||
p.DiffFn = testDiffFn
|
||||
|
||||
var value interface{}
|
||||
p.ConfigureFn = func(c *ResourceConfig) error {
|
||||
value, _ = c.Get("foo")
|
||||
return nil
|
||||
}
|
||||
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
Variables: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
})
|
||||
|
||||
if _, err := ctx.Plan(nil); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if value != "bar" {
|
||||
t.Fatalf("bad: %#v", value)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextPlan_varMultiCountOne(t *testing.T) {
|
||||
m := testModule(t, "plan-var-multi-count-one")
|
||||
p := testProvider("aws")
|
||||
|
7
terraform/test-fixtures/plan-provider/main.tf
Normal file
7
terraform/test-fixtures/plan-provider/main.tf
Normal file
@ -0,0 +1,7 @@
|
||||
variable "foo" {}
|
||||
|
||||
provider "aws" {
|
||||
foo = "${var.foo}"
|
||||
}
|
||||
|
||||
resource "aws_instance" "bar" {}
|
Loading…
Reference in New Issue
Block a user