mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
test a nil computed value within an expression
Comparing a nil-computed value was returning unknown, preventing the data source from being evaluated.
This commit is contained in:
parent
4836dffd81
commit
f0e51aca1a
@ -26,6 +26,11 @@ func testDataSource() *schema.Resource {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
// this attribute is computed, but never set by the provider
|
||||
"nil": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -155,3 +155,37 @@ data "test_data_source" "baz" {
|
||||
input = "${data.test_data_source.bar.*.output[count.index]}"
|
||||
}
|
||||
`
|
||||
|
||||
func TestDataSource_nilComputedValues(t *testing.T) {
|
||||
check := func(s *terraform.State) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
resource.UnitTest(t, resource.TestCase{
|
||||
Providers: testAccProviders,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Check: check,
|
||||
Config: `
|
||||
variable "index" {
|
||||
default = "d"
|
||||
}
|
||||
|
||||
locals {
|
||||
name = {
|
||||
a = "something"
|
||||
b = "else"
|
||||
}
|
||||
}
|
||||
|
||||
data "test_data_source" "x" {
|
||||
input = "${lookup(local.name, var.index, local.name["a"])}"
|
||||
}
|
||||
|
||||
data "test_data_source" "y" {
|
||||
input = data.test_data_source.x.nil == "something" ? "something" : "else"
|
||||
}`,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user