mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-15 19:22:46 -06:00
47604c36c8
The NewExtra values are stored outside the diff from plan, and the original keys may not contain the ~ prefix. Adding the NewExtra back into the diff with the mismatched key was causing an entire new set element to be populated. Since this symbol isn't used to apply the diff in helper/schema, we can simply strip them out.
72 lines
1.5 KiB
Go
72 lines
1.5 KiB
Go
package test
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
)
|
|
|
|
func TestResourceComputedSet_update(t *testing.T) {
|
|
resource.UnitTest(t, resource.TestCase{
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckResourceDestroy,
|
|
Steps: []resource.TestStep{
|
|
resource.TestStep{
|
|
Config: strings.TrimSpace(`
|
|
resource "test_resource_computed_set" "foo" {
|
|
}
|
|
`),
|
|
Check: resource.ComposeTestCheckFunc(
|
|
resource.TestCheckResourceAttr(
|
|
"test_resource_computed_set.foo", "string_set.#", "3",
|
|
),
|
|
),
|
|
},
|
|
resource.TestStep{
|
|
Config: strings.TrimSpace(`
|
|
resource "test_resource_computed_set" "foo" {
|
|
set_count = 5
|
|
}
|
|
`),
|
|
Check: resource.ComposeTestCheckFunc(
|
|
resource.TestCheckResourceAttr(
|
|
"test_resource_computed_set.foo", "string_set.#", "5",
|
|
),
|
|
),
|
|
},
|
|
resource.TestStep{
|
|
Config: strings.TrimSpace(`
|
|
resource "test_resource_computed_set" "foo" {
|
|
set_count = 2
|
|
}
|
|
`),
|
|
Check: resource.ComposeTestCheckFunc(
|
|
resource.TestCheckResourceAttr(
|
|
"test_resource_computed_set.foo", "string_set.#", "2",
|
|
),
|
|
),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func TestResourceComputedSet_ruleTest(t *testing.T) {
|
|
resource.UnitTest(t, resource.TestCase{
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckResourceDestroy,
|
|
Steps: []resource.TestStep{
|
|
resource.TestStep{
|
|
Config: strings.TrimSpace(`
|
|
resource "test_resource_computed_set" "foo" {
|
|
rule {
|
|
ip_protocol = "udp"
|
|
cidr = "0.0.0.0/0"
|
|
}
|
|
}
|
|
`),
|
|
},
|
|
},
|
|
})
|
|
}
|