@@ -1757,9 +1757,9 @@ func TestAccSQLDatabaseInstance_sqlMysqlDataCacheConfig(t *testing.T) {
17571757 CheckDestroy : testAccSqlDatabaseInstanceDestroyProducer (t ),
17581758 Steps : []resource.TestStep {
17591759 {
1760- Config : testGoogleSqlDatabaseInstance_sqlMysqlDataCacheConfig (instanceName ),
1760+ Config : testGoogleSqlDatabaseInstance_sqlMysqlDataCacheConfig (instanceName , false ),
17611761 Check : resource .ComposeAggregateTestCheckFunc (
1762- resource .TestCheckResourceAttr ("google_sql_database_instance.instance" , "settings.0.data_cache_config.0.data_cache_enabled" , "true " ),
1762+ resource .TestCheckResourceAttr ("google_sql_database_instance.instance" , "settings.0.data_cache_config.0.data_cache_enabled" , "false " ),
17631763 ),
17641764 },
17651765 {
@@ -1768,6 +1768,12 @@ func TestAccSQLDatabaseInstance_sqlMysqlDataCacheConfig(t *testing.T) {
17681768 ImportStateVerify : true ,
17691769 ImportStateVerifyIgnore : []string {"deletion_protection" },
17701770 },
1771+ {
1772+ Config : testGoogleSqlDatabaseInstance_sqlMysqlDataCacheConfig (instanceName , true ),
1773+ Check : resource .ComposeAggregateTestCheckFunc (
1774+ resource .TestCheckResourceAttr ("google_sql_database_instance.instance" , "settings.0.data_cache_config.0.data_cache_enabled" , "true" ),
1775+ ),
1776+ },
17711777 },
17721778 })
17731779}
@@ -1784,7 +1790,7 @@ func TestAccSQLDatabaseInstance_sqlPostgresDataCacheConfig(t *testing.T) {
17841790 CheckDestroy : testAccSqlDatabaseInstanceDestroyProducer (t ),
17851791 Steps : []resource.TestStep {
17861792 {
1787- Config : testGoogleSqlDatabaseInstance_sqlPostgresDataCacheConfig (enterprisePlusInstanceName , enterprisePlusTier , "ENTERPRISE_PLUS" ),
1793+ Config : testGoogleSqlDatabaseInstance_sqlPostgresDataCacheConfig (enterprisePlusInstanceName , enterprisePlusTier , "ENTERPRISE_PLUS" , true ),
17881794 Check : resource .ComposeAggregateTestCheckFunc (
17891795 resource .TestCheckResourceAttr ("google_sql_database_instance.instance" , "settings.0.data_cache_config.0.data_cache_enabled" , "true" ),
17901796 ),
@@ -1796,7 +1802,19 @@ func TestAccSQLDatabaseInstance_sqlPostgresDataCacheConfig(t *testing.T) {
17961802 ImportStateVerifyIgnore : []string {"deletion_protection" },
17971803 },
17981804 {
1799- Config : testGoogleSqlDatabaseInstance_sqlPostgresDataCacheConfig (enterpriseInstanceName , enterpriseTier , "ENTERPRISE" ),
1805+ Config : testGoogleSqlDatabaseInstance_sqlPostgresDataCacheConfig (enterprisePlusInstanceName , enterprisePlusTier , "ENTERPRISE_PLUS" , false ),
1806+ Check : resource .ComposeAggregateTestCheckFunc (
1807+ resource .TestCheckResourceAttr ("google_sql_database_instance.instance" , "settings.0.data_cache_config.0.data_cache_enabled" , "false" ),
1808+ ),
1809+ },
1810+ {
1811+ ResourceName : "google_sql_database_instance.instance" ,
1812+ ImportState : true ,
1813+ ImportStateVerify : true ,
1814+ ImportStateVerifyIgnore : []string {"deletion_protection" },
1815+ },
1816+ {
1817+ Config : testGoogleSqlDatabaseInstance_sqlPostgresDataCacheConfig (enterpriseInstanceName , enterpriseTier , "ENTERPRISE" , true ),
18001818 ExpectError : regexp .MustCompile (
18011819 fmt .Sprintf ("Error, failed to create instance %s: googleapi: Error 400: Invalid request: Only ENTERPRISE PLUS edition supports data cache" , enterpriseInstanceName )),
18021820 },
@@ -1826,7 +1844,7 @@ func TestAccSqlDatabaseInstance_Mysql_Edition_Upgrade(t *testing.T) {
18261844 ImportStateVerifyIgnore : []string {"deletion_protection" },
18271845 },
18281846 {
1829- Config : testGoogleSqlDatabaseInstance_sqlMysqlDataCacheConfig (editionUpgrade ),
1847+ Config : testGoogleSqlDatabaseInstance_sqlMysqlDataCacheConfig (editionUpgrade , true ),
18301848 Check : resource .ComposeAggregateTestCheckFunc (
18311849 resource .TestCheckResourceAttr ("google_sql_database_instance.instance" , "settings.0.edition" , "ENTERPRISE_PLUS" ),
18321850 resource .TestCheckResourceAttr ("google_sql_database_instance.instance" , "settings.0.data_cache_config.0.data_cache_enabled" , "true" ),
@@ -2901,7 +2919,7 @@ resource "google_sql_database_instance" "instance" {
29012919}` , databaseName , tier )
29022920}
29032921
2904- func testGoogleSqlDatabaseInstance_sqlMysqlDataCacheConfig (instanceName string ) string {
2922+ func testGoogleSqlDatabaseInstance_sqlMysqlDataCacheConfig (instanceName string , datacache bool ) string {
29052923 return fmt .Sprintf (`
29062924
29072925resource "google_sql_database_instance" "instance" {
@@ -2913,13 +2931,13 @@ resource "google_sql_database_instance" "instance" {
29132931 tier = "db-perf-optimized-N-2"
29142932 edition = "ENTERPRISE_PLUS"
29152933 data_cache_config {
2916- data_cache_enabled = true
2934+ data_cache_enabled = "%t"
29172935 }
29182936 }
2919- }` , instanceName )
2937+ }` , instanceName , datacache )
29202938}
29212939
2922- func testGoogleSqlDatabaseInstance_sqlPostgresDataCacheConfig (instanceName , tier , edition string ) string {
2940+ func testGoogleSqlDatabaseInstance_sqlPostgresDataCacheConfig (instanceName , tier , edition string , datacache bool ) string {
29232941 return fmt .Sprintf (`
29242942
29252943resource "google_sql_database_instance" "instance" {
@@ -2931,10 +2949,10 @@ resource "google_sql_database_instance" "instance" {
29312949 tier = "%s"
29322950 edition = "%s"
29332951 data_cache_config {
2934- data_cache_enabled = true
2952+ data_cache_enabled = "%t"
29352953 }
29362954 }
2937- }` , instanceName , tier , edition )
2955+ }` , instanceName , tier , edition , datacache )
29382956}
29392957
29402958func testGoogleSqlDatabaseInstance_SqlServerTimezone (instance , rootPassword , timezone string ) string {
0 commit comments