Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed Feb 20, 2024
1 parent 46c33fe commit 9dac7b3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
22 changes: 20 additions & 2 deletions pkg/resources/database_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,22 @@ func TestAcc_Database_DefaultDataRetentionTime(t *testing.T) {
return vars
}

client, err := sdk.NewDefaultClient()
require.NoError(t, err)

ctx := context.Background()
param, err := client.Parameters.ShowAccountParameter(ctx, sdk.AccountParameterDataRetentionTimeInDays)
require.NoError(t, err)

resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
PreCheck: func() { acc.TestAccPreCheck(t) },
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(tfversion.Version1_5_0),
},
CheckDestroy: nil,
CheckDestroy: func(state *terraform.State) error {
return client.Parameters.SetAccountParameter(ctx, sdk.AccountParameterDataRetentionTimeInDays, param.Value)
},
Steps: []resource.TestStep{
{
ConfigDirectory: acc.ConfigurationDirectory("TestAcc_Database_DefaultDataRetentionTime/WithoutDatabase"),
Expand Down Expand Up @@ -283,13 +292,22 @@ func TestAcc_Database_DefaultDataRetentionTime_SetOutsideOfTerraform(t *testing.
return vars
}

client, err := sdk.NewDefaultClient()
require.NoError(t, err)

ctx := context.Background()
param, err := client.Parameters.ShowAccountParameter(ctx, sdk.AccountParameterDataRetentionTimeInDays)
require.NoError(t, err)

resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories,
PreCheck: func() { acc.TestAccPreCheck(t) },
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.RequireAbove(tfversion.Version1_5_0),
},
CheckDestroy: nil,
CheckDestroy: func(state *terraform.State) error {
return client.Parameters.SetAccountParameter(ctx, sdk.AccountParameterDataRetentionTimeInDays, param.Value)
},
Steps: []resource.TestStep{
{
ConfigDirectory: acc.ConfigurationDirectory("TestAcc_Database_DefaultDataRetentionTime/WithoutDatabase"),
Expand Down
18 changes: 1 addition & 17 deletions pkg/resources/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,6 @@ func CreateTable(d *schema.ResourceData, meta interface{}) error {
if v := d.Get("data_retention_time_in_days"); v.(int) != -1 {
createRequest.WithDataRetentionTimeInDays(sdk.Int(v.(int)))
}
// else if v, ok := d.GetOk("data_retention_days"); ok { // TODO: I would remove it
// createRequest.WithDataRetentionTimeInDays(sdk.Int(v.(int)))
//}

if v, ok := d.GetOk("change_tracking"); ok {
createRequest.WithChangeTracking(sdk.Bool(v.(bool)))
Expand Down Expand Up @@ -662,15 +659,8 @@ func ReadTable(d *schema.ResourceData, meta interface{}) error {
"change_tracking": table.ChangeTracking,
"qualified_name": id.FullyQualifiedName(),
}
var dataRetentionKey string
if v := d.Get("data_retention_time_in_days"); v.(int) != -1 || int64(table.RetentionTime) != schemaRetentionTime {
dataRetentionKey = "data_retention_time_in_days"
}
// else if _, ok := d.GetOk("data_retention_days"); ok { // TODO: I would remove it
// dataRetentionKey = "data_retention_days"
//}
if dataRetentionKey != "" {
toSet[dataRetentionKey] = table.RetentionTime
toSet["data_retention_time_in_days"] = table.RetentionTime
}

for key, val := range toSet {
Expand Down Expand Up @@ -724,12 +714,6 @@ func UpdateTable(d *schema.ResourceData, meta interface{}) error {
setRequest.WithChangeTracking(sdk.Bool(changeTracking))
}

// if d.HasChange("data_retention_days") { // TODO: I would remove it
// dataRetentionDays := d.Get("data_retention_days").(int)
// runSetStatement = true
// setRequest.WithDataRetentionTimeInDays(sdk.Int(dataRetentionDays))
//}

if d.HasChange("data_retention_time_in_days") {
if days := d.Get("data_retention_time_in_days"); days.(int) != -1 {
runSetStatement = true
Expand Down

0 comments on commit 9dac7b3

Please sign in to comment.