mirror of https://github.com/hashicorp/terraform
parent
7644093280
commit
da4cf6b5c1
@ -0,0 +1,15 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
test = {
|
||||
source = "hashicorp/test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "test_complex_data_source" "datasource" {
|
||||
id = "resource"
|
||||
}
|
||||
|
||||
output "nested_set_value" {
|
||||
value = data.test_complex_data_source.datasource.nested_set_value
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
provider "test" {}
|
||||
|
||||
override_data {
|
||||
target = data.test_complex_data_source.datasource
|
||||
values = {
|
||||
nested_set_value = {
|
||||
name = "shared"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
run "test_override_data_complex_nested_set_attribute_object" {
|
||||
command = plan
|
||||
|
||||
assert {
|
||||
condition = length(data.test_complex_data_source.datasource.nested_set_value) == 0
|
||||
error_message = "Expected nested_set_value to be empty when overridden with an object"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
test = {
|
||||
source = "hashicorp/test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "test_complex_data_source" "datasource" {
|
||||
id = "resource"
|
||||
}
|
||||
|
||||
output "set_value" {
|
||||
value = data.test_complex_data_source.datasource.set_value
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
provider "test" {}
|
||||
|
||||
override_data {
|
||||
target = data.test_complex_data_source.datasource
|
||||
values = {
|
||||
set_value = [
|
||||
{
|
||||
name = "first"
|
||||
},
|
||||
{
|
||||
value = "two"
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
run "test_override_data_complex_set_attribute_partial_elements" {
|
||||
command = plan
|
||||
|
||||
assert {
|
||||
condition = length(data.test_complex_data_source.datasource.set_value) == 2
|
||||
error_message = "Expected set_value to have 2 elements, got ${length(data.test_complex_data_source.datasource.set_value)}"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = length([
|
||||
for item in data.test_complex_data_source.datasource.set_value : item
|
||||
if item.name == "first" && item.value != null
|
||||
]) == 1
|
||||
error_message = "Expected one set_value element with name 'first' and a filled-in value"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = length([
|
||||
for item in data.test_complex_data_source.datasource.set_value : item
|
||||
if item.value == "two" && item.name != null
|
||||
]) == 1
|
||||
error_message = "Expected one set_value element with value 'two' and a filled-in name"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
test = {
|
||||
source = "hashicorp/test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "test_data_source" "datasource" {
|
||||
id = "resource"
|
||||
}
|
||||
|
||||
output "list_value" {
|
||||
value = data.test_data_source.datasource.list_value
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
provider "test" {}
|
||||
|
||||
override_data {
|
||||
target = data.test_data_source.datasource
|
||||
values = {
|
||||
list_value = [
|
||||
{
|
||||
name = "first"
|
||||
},
|
||||
{
|
||||
value = "two"
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
run "test_override_data_list_attribute_partial_elements" {
|
||||
command = plan
|
||||
|
||||
assert {
|
||||
condition = length(data.test_data_source.datasource.list_value) == 2
|
||||
error_message = "Expected list_value to have 2 elements, got ${length(data.test_data_source.datasource.list_value)}"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = data.test_data_source.datasource.list_value[0].name == "first"
|
||||
error_message = "Expected first element name to be 'first'"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = data.test_data_source.datasource.list_value[0].value != null
|
||||
error_message = "Expected first element value to be filled in"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = data.test_data_source.datasource.list_value[1].value == "two"
|
||||
error_message = "Expected second element value to be 'two'"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = data.test_data_source.datasource.list_value[1].name != null
|
||||
error_message = "Expected second element name to be filled in"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
test = {
|
||||
source = "hashicorp/test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "test_data_source" "datasource" {
|
||||
id = "resource"
|
||||
}
|
||||
|
||||
output "nested_list_value" {
|
||||
value = data.test_data_source.datasource.nested_list_value
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
provider "test" {}
|
||||
|
||||
override_data {
|
||||
target = data.test_data_source.datasource
|
||||
values = {
|
||||
nested_list_value = "wrong type"
|
||||
}
|
||||
}
|
||||
|
||||
run "test_override_data_nested_list_attribute_invalid_type" {
|
||||
command = plan
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
test = {
|
||||
source = "hashicorp/test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "test_data_source" "datasource" {
|
||||
id = "resource"
|
||||
}
|
||||
|
||||
output "nested_list_value" {
|
||||
value = data.test_data_source.datasource.nested_list_value
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
provider "test" {}
|
||||
|
||||
override_data {
|
||||
target = data.test_data_source.datasource
|
||||
values = {
|
||||
nested_list_value = {
|
||||
name = "shared"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
run "test_override_data_nested_list_attribute_object" {
|
||||
command = plan
|
||||
|
||||
assert {
|
||||
condition = length(data.test_data_source.datasource.nested_list_value) == 0
|
||||
error_message = "Expected nested_list_value to be empty when overridden with an object"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
test = {
|
||||
source = "hashicorp/test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "test_data_source" "datasource" {
|
||||
id = "resource"
|
||||
}
|
||||
|
||||
output "nested_list_value" {
|
||||
value = data.test_data_source.datasource.nested_list_value
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
provider "test" {}
|
||||
|
||||
override_data {
|
||||
target = data.test_data_source.datasource
|
||||
values = {
|
||||
nested_list_value = [
|
||||
{
|
||||
name = "first"
|
||||
},
|
||||
{
|
||||
value = "two"
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
run "test_override_data_nested_list_attribute_partial_elements" {
|
||||
command = plan
|
||||
|
||||
assert {
|
||||
condition = length(data.test_data_source.datasource.nested_list_value) == 2
|
||||
error_message = "Expected nested_list_value to have 2 elements, got ${length(data.test_data_source.datasource.nested_list_value)}"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = data.test_data_source.datasource.nested_list_value[0].name == "first"
|
||||
error_message = "Expected first element name to be 'first'"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = data.test_data_source.datasource.nested_list_value[0].value != null
|
||||
error_message = "Expected first element value to be filled in"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = data.test_data_source.datasource.nested_list_value[1].value == "two"
|
||||
error_message = "Expected second element value to be 'two'"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = data.test_data_source.datasource.nested_list_value[1].name != null
|
||||
error_message = "Expected second element name to be filled in"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue