mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
8212a6a9d0
Adding and removing a single map that requires a new resource can cause empty diffs, relying on the core proposed state values for destruction.
80 lines
1.5 KiB
Go
80 lines
1.5 KiB
Go
package test
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
)
|
|
|
|
func TestResourceForceNew_create(t *testing.T) {
|
|
resource.UnitTest(t, resource.TestCase{
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckResourceDestroy,
|
|
Steps: []resource.TestStep{
|
|
resource.TestStep{
|
|
Config: strings.TrimSpace(`
|
|
resource "test_resource_force_new" "foo" {
|
|
triggers = {
|
|
"a" = "foo"
|
|
}
|
|
}`),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
func TestResourceForceNew_update(t *testing.T) {
|
|
resource.UnitTest(t, resource.TestCase{
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckResourceDestroy,
|
|
Steps: []resource.TestStep{
|
|
resource.TestStep{
|
|
Config: strings.TrimSpace(`
|
|
resource "test_resource_force_new" "foo" {
|
|
triggers = {
|
|
"a" = "foo"
|
|
}
|
|
}`),
|
|
},
|
|
resource.TestStep{
|
|
Config: strings.TrimSpace(`
|
|
resource "test_resource_force_new" "foo" {
|
|
triggers = {
|
|
"a" = "bar"
|
|
}
|
|
}`),
|
|
},
|
|
resource.TestStep{
|
|
Config: strings.TrimSpace(`
|
|
resource "test_resource_force_new" "foo" {
|
|
triggers = {
|
|
"b" = "bar"
|
|
}
|
|
}`),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func TestResourceForceNew_remove(t *testing.T) {
|
|
resource.UnitTest(t, resource.TestCase{
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckResourceDestroy,
|
|
Steps: []resource.TestStep{
|
|
resource.TestStep{
|
|
Config: strings.TrimSpace(`
|
|
resource "test_resource_force_new" "foo" {
|
|
triggers = {
|
|
"a" = "bar"
|
|
}
|
|
}`),
|
|
},
|
|
resource.TestStep{
|
|
Config: strings.TrimSpace(`
|
|
resource "test_resource_force_new" "foo" {
|
|
} `),
|
|
},
|
|
},
|
|
})
|
|
}
|