2018-05-23 18:25:48 +00:00
|
|
|
package google
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
|
|
)
|
|
|
|
|
2018-06-05 00:41:48 +00:00
|
|
|
func TestAccRedisInstance_update(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
name := acctest.RandomWithPrefix("tf-test")
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
2018-06-06 17:55:04 +00:00
|
|
|
CheckDestroy: testAccCheckRedisInstanceDestroy,
|
2018-06-05 00:41:48 +00:00
|
|
|
Steps: []resource.TestStep{
|
2018-12-14 20:51:11 +00:00
|
|
|
{
|
2018-06-05 00:41:48 +00:00
|
|
|
Config: testAccRedisInstance_update(name),
|
|
|
|
},
|
2018-12-14 20:51:11 +00:00
|
|
|
{
|
2018-06-05 00:41:48 +00:00
|
|
|
ResourceName: "google_redis_instance.test",
|
|
|
|
ImportState: true,
|
|
|
|
ImportStateVerify: true,
|
|
|
|
},
|
2018-12-14 20:51:11 +00:00
|
|
|
{
|
2018-06-05 00:41:48 +00:00
|
|
|
Config: testAccRedisInstance_update2(name),
|
|
|
|
},
|
2018-12-14 20:51:11 +00:00
|
|
|
{
|
2018-06-05 00:41:48 +00:00
|
|
|
ResourceName: "google_redis_instance.test",
|
|
|
|
ImportState: true,
|
|
|
|
ImportStateVerify: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func testAccRedisInstance_update(name string) string {
|
|
|
|
return fmt.Sprintf(`
|
|
|
|
resource "google_redis_instance" "test" {
|
|
|
|
name = "%s"
|
|
|
|
display_name = "pre-update"
|
|
|
|
memory_size_gb = 1
|
2018-10-04 17:27:17 +00:00
|
|
|
region = "us-central1"
|
2018-06-05 00:41:48 +00:00
|
|
|
|
2018-12-27 15:51:23 +00:00
|
|
|
labels = {
|
2018-06-05 00:41:48 +00:00
|
|
|
my_key = "my_val"
|
|
|
|
other_key = "other_val"
|
|
|
|
}
|
2018-07-02 17:16:38 +00:00
|
|
|
|
|
|
|
redis_configs {
|
|
|
|
maxmemory-policy = "allkeys-lru"
|
|
|
|
notify-keyspace-events = "KEA"
|
|
|
|
}
|
2018-06-05 00:41:48 +00:00
|
|
|
}`, name)
|
|
|
|
}
|
|
|
|
|
|
|
|
func testAccRedisInstance_update2(name string) string {
|
|
|
|
return fmt.Sprintf(`
|
|
|
|
resource "google_redis_instance" "test" {
|
|
|
|
name = "%s"
|
|
|
|
display_name = "post-update"
|
|
|
|
memory_size_gb = 1
|
|
|
|
|
2018-12-27 15:51:23 +00:00
|
|
|
labels = {
|
2018-06-05 00:41:48 +00:00
|
|
|
my_key = "my_val"
|
|
|
|
other_key = "new_val"
|
|
|
|
}
|
2018-07-02 17:16:38 +00:00
|
|
|
|
|
|
|
redis_configs {
|
|
|
|
maxmemory-policy = "noeviction"
|
|
|
|
notify-keyspace-events = ""
|
|
|
|
}
|
2018-06-05 00:41:48 +00:00
|
|
|
}`, name)
|
|
|
|
}
|