Skip to content

Commit

Permalink
Fix warehouse and user
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-asawicki committed Sep 3, 2024
1 parent 82649d4 commit 4b5dc10
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
3 changes: 2 additions & 1 deletion pkg/resources/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ func User() *schema.Resource {

CustomizeDiff: customdiff.All(
// TODO [SNOW-1629468 - next pr]: test "default_role", "default_secondary_roles"
ComputedIfAnyAttributeChanged(userSchema, ShowOutputAttributeName, "password", "login_name", "display_name", "first_name", "middle_name", "last_name", "email", "must_change_password", "disabled", "days_to_expiry", "mins_to_unlock", "default_warehouse", "default_namespace", "default_role", "default_secondary_roles", "mins_to_bypass_mfa", "rsa_public_key", "rsa_public_key_2", "comment", "disable_mfa"),
// TODO [SNOW-TODO]: "default_secondary_roles" have to stay commented out because of how the SDKv2 handles diff suppressions and custom diffs for sets
ComputedIfAnyAttributeChanged(userSchema, ShowOutputAttributeName, "password", "login_name", "display_name", "first_name", "middle_name", "last_name", "email", "must_change_password", "disabled", "days_to_expiry", "mins_to_unlock", "default_warehouse", "default_namespace", "default_role", "mins_to_bypass_mfa", "rsa_public_key", "rsa_public_key_2", "comment", "disable_mfa"),
ComputedIfAnyAttributeChanged(userParametersSchema, ParametersAttributeName, collections.Map(sdk.AsStringList(sdk.AllUserParameters), strings.ToLower)...),
ComputedIfAnyAttributeChanged(userSchema, FullyQualifiedNameAttributeName, "name"),
userParametersCustomDiff,
Expand Down
30 changes: 2 additions & 28 deletions pkg/resources/warehouse_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,41 +188,15 @@ func TestAcc_Warehouse_BasicFlows(t *testing.T) {
resource.TestCheckResourceAttr("snowflake_warehouse.w", "fully_qualified_name", warehouseId2.FullyQualifiedName()),
),
},
// Change config but use defaults for every attribute (but not the parameters) - expect no changes (because these are already SF values) except computed show_output (follow-up why suppress diff is not taken into account in has changes?)
// Change config but use defaults for every attribute (but not the parameters) - expect no changes (because these are already SF values)
{
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
planchecks.PrintPlanDetails("snowflake_warehouse.w", "warehouse_type", "warehouse_size", "max_cluster_count", "min_cluster_count", "scaling_policy", "auto_suspend", "auto_resume", "enable_query_acceleration", "query_acceleration_max_scale_factor", "max_concurrency_level", "statement_queued_timeout_in_seconds", "statement_timeout_in_seconds", r.ShowOutputAttributeName),
plancheck.ExpectResourceAction("snowflake_warehouse.w", plancheck.ResourceActionUpdate),
planchecks.ExpectComputed("snowflake_warehouse.w", r.ShowOutputAttributeName, true),
plancheck.ExpectEmptyPlan(),
},
},
Config: warehouseFullDefaultWithoutParametersConfig(name2, comment),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_type", string(sdk.WarehouseTypeStandard)),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_size", string(sdk.WarehouseSizeXSmall)),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "max_cluster_count", "1"),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "min_cluster_count", "1"),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "scaling_policy", string(sdk.ScalingPolicyStandard)),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_suspend", "600"),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_resume", "true"),
resource.TestCheckNoResourceAttr("snowflake_warehouse.w", "initially_suspended"),
resource.TestCheckNoResourceAttr("snowflake_warehouse.w", "resource_monitor"),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "comment", comment),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "enable_query_acceleration", "false"),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "query_acceleration_max_scale_factor", "8"),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "max_concurrency_level", "8"),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "statement_queued_timeout_in_seconds", "0"),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "statement_timeout_in_seconds", "172800"),

resource.TestCheckResourceAttr("snowflake_warehouse.w", "parameters.#", "1"),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "parameters.0.max_concurrency_level.0.value", "8"),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "parameters.0.max_concurrency_level.0.level", ""),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "parameters.0.statement_queued_timeout_in_seconds.0.value", "0"),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "parameters.0.statement_queued_timeout_in_seconds.0.level", ""),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "parameters.0.statement_timeout_in_seconds.0.value", "172800"),
resource.TestCheckResourceAttr("snowflake_warehouse.w", "parameters.0.statement_timeout_in_seconds.0.level", ""),
),
},
// add parameters - update expected (different level even with same values)
{
Expand Down

0 comments on commit 4b5dc10

Please sign in to comment.