From ad657eb1e04d56b22001828fa9f22f160e7c6494 Mon Sep 17 00:00:00 2001 From: Artur Sawicki Date: Mon, 2 Sep 2024 14:50:20 +0200 Subject: [PATCH] chore: Clean old assertions (#3029) Clean old assertions: - replace `checkBool` - replace `snowflakechecks` for warehouse with already generated new assertions - replace `snowflakechecks` for database with new generated assertions - generated object assertions for the database - generated parameter assertions for the database - written assertions for the database describe (they are not generateable yet) Other: - renamed methods in `resource_helpers_read.go` --- pkg/acceptance/bettertestspoc/README.md | 2 +- .../objectassert/database_snowflake_gen.go | 189 ++++++++ .../describe_database_snowflake_ext.go | 46 ++ .../assert/objectassert/gen/sdk_object_def.go | 15 +- .../database_parameters_snowflake_gen.go | 410 ++++++++++++++++++ .../gen/object_parameters_def.go | 23 + .../assert/snowflake_assertions.go | 4 + pkg/acceptance/helpers/database_client.go | 7 +- pkg/acceptance/snowflakechecks/database.go | 49 --- pkg/acceptance/snowflakechecks/warehouse.go | 68 --- .../genhelpers/struct_details_extractor.go | 7 +- pkg/resources/alert_acceptance_test.go | 10 +- pkg/resources/database_acceptance_test.go | 77 ++-- pkg/resources/deprecated_test.go | 24 - .../materialized_view_acceptance_test.go | 8 +- pkg/resources/password_policy.go | 22 +- pkg/resources/resource_helpers_read.go | 9 +- pkg/resources/stream_acceptance_test.go | 36 +- pkg/resources/task_acceptance_test.go | 50 +-- pkg/resources/user.go | 24 +- pkg/resources/view_acceptance_test.go | 8 +- pkg/resources/warehouse_acceptance_test.go | 201 +++++---- pkg/sdk/parameters.go | 21 + 23 files changed, 934 insertions(+), 376 deletions(-) create mode 100644 pkg/acceptance/bettertestspoc/assert/objectassert/database_snowflake_gen.go create mode 100644 pkg/acceptance/bettertestspoc/assert/objectassert/describe_database_snowflake_ext.go create mode 100644 pkg/acceptance/bettertestspoc/assert/objectparametersassert/database_parameters_snowflake_gen.go delete mode 100644 pkg/acceptance/snowflakechecks/database.go delete mode 100644 pkg/acceptance/snowflakechecks/warehouse.go delete mode 100644 pkg/resources/deprecated_test.go diff --git a/pkg/acceptance/bettertestspoc/README.md b/pkg/acceptance/bettertestspoc/README.md index 3dca522056..09cae6cd38 100644 --- a/pkg/acceptance/bettertestspoc/README.md +++ b/pkg/acceptance/bettertestspoc/README.md @@ -321,7 +321,7 @@ it will result in: - Replace `acceptance/snowflakechecks` with the new proposed Snowflake objects assertions. - Support `showOutputValueUnset` and add a second function for each `show_output` attribute. - Support `resourceAssertionTypeValueNotSet` for import checks (`panic` left currently). -- Add assertions for the `describe_output`. +- Add assertions for the `describe_output` and handle describe objects too. - Add support for datasource tests (assertions and config builders). - Consider overriding the assertions when invoking same check multiple times with different params (e.g. `Warehouse(...).HasType(X).HasType(Y)`; it could use the last-check-wins approach, to more easily reuse complex checks between the test steps). - Consider not adding the check for `show_output` presence on creation (same with `parameters`). The majority of the use cases need it to be present but there are a few others (like conditional presence in the datasources). Currently, it seems that they should be always present in the resources, so no change is made. Later, with adding the support for the datasource tests, consider simple destructive implementation like: diff --git a/pkg/acceptance/bettertestspoc/assert/objectassert/database_snowflake_gen.go b/pkg/acceptance/bettertestspoc/assert/objectassert/database_snowflake_gen.go new file mode 100644 index 0000000000..e7a852313b --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/objectassert/database_snowflake_gen.go @@ -0,0 +1,189 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package objectassert + +import ( + "fmt" + "testing" + "time" + + acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +type DatabaseAssert struct { + *assert.SnowflakeObjectAssert[sdk.Database, sdk.AccountObjectIdentifier] +} + +func Database(t *testing.T, id sdk.AccountObjectIdentifier) *DatabaseAssert { + t.Helper() + return &DatabaseAssert{ + assert.NewSnowflakeObjectAssertWithProvider(sdk.ObjectTypeDatabase, id, acc.TestClient().Database.Show), + } +} + +func DatabaseFromObject(t *testing.T, database *sdk.Database) *DatabaseAssert { + t.Helper() + return &DatabaseAssert{ + assert.NewSnowflakeObjectAssertWithObject(sdk.ObjectTypeDatabase, database.ID(), database), + } +} + +func (d *DatabaseAssert) HasCreatedOn(expected time.Time) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.CreatedOn != expected { + return fmt.Errorf("expected created on: %v; got: %v", expected, o.CreatedOn) + } + return nil + }) + return d +} + +func (d *DatabaseAssert) HasName(expected string) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.Name != expected { + return fmt.Errorf("expected name: %v; got: %v", expected, o.Name) + } + return nil + }) + return d +} + +func (d *DatabaseAssert) HasIsDefault(expected bool) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.IsDefault != expected { + return fmt.Errorf("expected is default: %v; got: %v", expected, o.IsDefault) + } + return nil + }) + return d +} + +func (d *DatabaseAssert) HasIsCurrent(expected bool) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.IsCurrent != expected { + return fmt.Errorf("expected is current: %v; got: %v", expected, o.IsCurrent) + } + return nil + }) + return d +} + +func (d *DatabaseAssert) HasOrigin(expected sdk.ExternalObjectIdentifier) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.Origin == nil { + return fmt.Errorf("expected origin to have value; got: nil") + } + if *o.Origin != expected { + return fmt.Errorf("expected origin: %v; got: %v", expected, *o.Origin) + } + return nil + }) + return d +} + +func (d *DatabaseAssert) HasOwner(expected string) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.Owner != expected { + return fmt.Errorf("expected owner: %v; got: %v", expected, o.Owner) + } + return nil + }) + return d +} + +func (d *DatabaseAssert) HasComment(expected string) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.Comment != expected { + return fmt.Errorf("expected comment: %v; got: %v", expected, o.Comment) + } + return nil + }) + return d +} + +func (d *DatabaseAssert) HasOptions(expected string) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.Options != expected { + return fmt.Errorf("expected options: %v; got: %v", expected, o.Options) + } + return nil + }) + return d +} + +func (d *DatabaseAssert) HasRetentionTime(expected int) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.RetentionTime != expected { + return fmt.Errorf("expected retention time: %v; got: %v", expected, o.RetentionTime) + } + return nil + }) + return d +} + +func (d *DatabaseAssert) HasResourceGroup(expected string) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.ResourceGroup != expected { + return fmt.Errorf("expected resource group: %v; got: %v", expected, o.ResourceGroup) + } + return nil + }) + return d +} + +func (d *DatabaseAssert) HasDroppedOn(expected time.Time) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.DroppedOn != expected { + return fmt.Errorf("expected dropped on: %v; got: %v", expected, o.DroppedOn) + } + return nil + }) + return d +} + +func (d *DatabaseAssert) HasTransient(expected bool) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.Transient != expected { + return fmt.Errorf("expected transient: %v; got: %v", expected, o.Transient) + } + return nil + }) + return d +} + +func (d *DatabaseAssert) HasKind(expected string) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.Kind != expected { + return fmt.Errorf("expected kind: %v; got: %v", expected, o.Kind) + } + return nil + }) + return d +} + +func (d *DatabaseAssert) HasOwnerRoleType(expected string) *DatabaseAssert { + d.AddAssertion(func(t *testing.T, o *sdk.Database) error { + t.Helper() + if o.OwnerRoleType != expected { + return fmt.Errorf("expected owner role type: %v; got: %v", expected, o.OwnerRoleType) + } + return nil + }) + return d +} diff --git a/pkg/acceptance/bettertestspoc/assert/objectassert/describe_database_snowflake_ext.go b/pkg/acceptance/bettertestspoc/assert/objectassert/describe_database_snowflake_ext.go new file mode 100644 index 0000000000..e92a949e90 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/objectassert/describe_database_snowflake_ext.go @@ -0,0 +1,46 @@ +package objectassert + +import ( + "fmt" + "slices" + "testing" + + acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +// TODO [SNOW-1501905]: this file should be fully regenerated when adding and option to assert the results of describe +type DatabaseDescribeAssert struct { + *assert.SnowflakeObjectAssert[sdk.DatabaseDetails, sdk.AccountObjectIdentifier] +} + +func DatabaseDescribe(t *testing.T, id sdk.AccountObjectIdentifier) *DatabaseDescribeAssert { + t.Helper() + return &DatabaseDescribeAssert{ + assert.NewSnowflakeObjectAssertWithProvider(sdk.ObjectType("DATABASE_DETAILS"), id, acc.TestClient().Database.Describe), + } +} + +func (d *DatabaseDescribeAssert) DoesNotContainPublicSchema() *DatabaseDescribeAssert { + d.AddAssertion(func(t *testing.T, o *sdk.DatabaseDetails) error { + t.Helper() + if slices.ContainsFunc(o.Rows, func(row sdk.DatabaseDetailsRow) bool { return row.Name == "PUBLIC" && row.Kind == "SCHEMA" }) { + return fmt.Errorf("expected database %s to not contain public schema", d.GetId()) + } + return nil + }) + return d +} + +func (d *DatabaseDescribeAssert) ContainsPublicSchema() *DatabaseDescribeAssert { + d.AddAssertion(func(t *testing.T, o *sdk.DatabaseDetails) error { + t.Helper() + if !slices.ContainsFunc(o.Rows, func(row sdk.DatabaseDetailsRow) bool { return row.Name == "PUBLIC" && row.Kind == "SCHEMA" }) { + return fmt.Errorf("expected database %s to contain public schema", d.GetId()) + } + return nil + }) + return d +} diff --git a/pkg/acceptance/bettertestspoc/assert/objectassert/gen/sdk_object_def.go b/pkg/acceptance/bettertestspoc/assert/objectassert/gen/sdk_object_def.go index 65c3abf062..798b2dbdcc 100644 --- a/pkg/acceptance/bettertestspoc/assert/objectassert/gen/sdk_object_def.go +++ b/pkg/acceptance/bettertestspoc/assert/objectassert/gen/sdk_object_def.go @@ -12,6 +12,11 @@ type SdkObjectDef struct { } var allStructs = []SdkObjectDef{ + { + IdType: "sdk.AccountObjectIdentifier", + ObjectType: sdk.ObjectTypeDatabase, + ObjectStruct: sdk.Database{}, + }, { IdType: "sdk.DatabaseObjectIdentifier", ObjectType: sdk.ObjectTypeDatabaseRole, @@ -22,16 +27,16 @@ var allStructs = []SdkObjectDef{ ObjectType: sdk.ObjectTypeUser, ObjectStruct: sdk.User{}, }, - { - IdType: "sdk.AccountObjectIdentifier", - ObjectType: sdk.ObjectTypeWarehouse, - ObjectStruct: sdk.Warehouse{}, - }, { IdType: "sdk.SchemaObjectIdentifier", ObjectType: sdk.ObjectTypeView, ObjectStruct: sdk.View{}, }, + { + IdType: "sdk.AccountObjectIdentifier", + ObjectType: sdk.ObjectTypeWarehouse, + ObjectStruct: sdk.Warehouse{}, + }, } func GetSdkObjectDetails() []genhelpers.SdkObjectDetails { diff --git a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/database_parameters_snowflake_gen.go b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/database_parameters_snowflake_gen.go new file mode 100644 index 0000000000..6c33814187 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/database_parameters_snowflake_gen.go @@ -0,0 +1,410 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package objectparametersassert + +import ( + "testing" + + acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" +) + +type DatabaseParametersAssert struct { + *assert.SnowflakeParametersAssert[sdk.AccountObjectIdentifier] +} + +func DatabaseParameters(t *testing.T, id sdk.AccountObjectIdentifier) *DatabaseParametersAssert { + t.Helper() + return &DatabaseParametersAssert{ + assert.NewSnowflakeParametersAssertWithProvider(id, sdk.ObjectTypeDatabase, acc.TestClient().Parameter.ShowDatabaseParameters), + } +} + +func DatabaseParametersPrefetched(t *testing.T, id sdk.AccountObjectIdentifier, parameters []*sdk.Parameter) *DatabaseParametersAssert { + t.Helper() + return &DatabaseParametersAssert{ + assert.NewSnowflakeParametersAssertWithParameters(id, sdk.ObjectTypeDatabase, parameters), + } +} + +////////////////////////////// +// Generic parameter checks // +////////////////////////////// + +func (d *DatabaseParametersAssert) HasBoolParameterValue(parameterName sdk.DatabaseParameter, expected bool) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterBoolValueSet(parameterName, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasIntParameterValue(parameterName sdk.DatabaseParameter, expected int) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterIntValueSet(parameterName, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasStringParameterValue(parameterName sdk.DatabaseParameter, expected string) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterValueSet(parameterName, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasDefaultParameterValue(parameterName sdk.DatabaseParameter) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterDefaultValueSet(parameterName)) + return d +} + +func (d *DatabaseParametersAssert) HasDefaultParameterValueOnLevel(parameterName sdk.DatabaseParameter, parameterType sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterDefaultValueOnLevelSet(parameterName, parameterType)) + return d +} + +/////////////////////////////// +// Aggregated generic checks // +/////////////////////////////// + +// HasAllDefaults checks if all the parameters: +// - have a default value by comparing current value of the sdk.Parameter with its default +// - have an expected level +func (d *DatabaseParametersAssert) HasAllDefaults() *DatabaseParametersAssert { + return d. + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterDataRetentionTimeInDays, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterMaxDataExtensionTimeInDays, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterExternalVolume, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterCatalog, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterReplaceInvalidCharacters, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterDefaultDdlCollation, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterStorageSerializationPolicy, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterLogLevel, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterTraceLevel, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterSuspendTaskAfterNumFailures, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterTaskAutoRetryAttempts, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterUserTaskManagedInitialWarehouseSize, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterUserTaskTimeoutMs, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterUserTaskMinimumTriggerIntervalInSeconds, sdk.ParameterTypeSnowflakeDefault). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterQuotedIdentifiersIgnoreCase, sdk.ParameterTypeAccount). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterEnableConsoleOutput, sdk.ParameterTypeSnowflakeDefault) +} + +func (d *DatabaseParametersAssert) HasAllDefaultsExplicit() *DatabaseParametersAssert { + return d. + HasDefaultDataRetentionTimeInDaysValueExplicit(). + HasDefaultMaxDataExtensionTimeInDaysValueExplicit(). + HasDefaultExternalVolumeValueExplicit(). + HasDefaultCatalogValueExplicit(). + HasDefaultReplaceInvalidCharactersValueExplicit(). + HasDefaultDefaultDdlCollationValueExplicit(). + HasDefaultStorageSerializationPolicyValueExplicit(). + HasDefaultLogLevelValueExplicit(). + HasDefaultTraceLevelValueExplicit(). + HasDefaultSuspendTaskAfterNumFailuresValueExplicit(). + HasDefaultTaskAutoRetryAttemptsValueExplicit(). + HasDefaultUserTaskManagedInitialWarehouseSizeValueExplicit(). + HasDefaultUserTaskTimeoutMsValueExplicit(). + HasDefaultUserTaskMinimumTriggerIntervalInSecondsValueExplicit(). + HasDefaultQuotedIdentifiersIgnoreCaseValueExplicit(). + HasDefaultEnableConsoleOutputValueExplicit() +} + +//////////////////////////// +// Parameter value checks // +//////////////////////////// + +func (d *DatabaseParametersAssert) HasDataRetentionTimeInDays(expected int) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterIntValueSet(sdk.DatabaseParameterDataRetentionTimeInDays, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasMaxDataExtensionTimeInDays(expected int) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterIntValueSet(sdk.DatabaseParameterMaxDataExtensionTimeInDays, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasExternalVolume(expected string) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterValueSet(sdk.DatabaseParameterExternalVolume, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasCatalog(expected string) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterValueSet(sdk.DatabaseParameterCatalog, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasReplaceInvalidCharacters(expected bool) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterBoolValueSet(sdk.DatabaseParameterReplaceInvalidCharacters, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasDefaultDdlCollation(expected string) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterValueSet(sdk.DatabaseParameterDefaultDdlCollation, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasStorageSerializationPolicy(expected sdk.StorageSerializationPolicy) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterStringUnderlyingValueSet(sdk.DatabaseParameterStorageSerializationPolicy, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasLogLevel(expected sdk.LogLevel) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterStringUnderlyingValueSet(sdk.DatabaseParameterLogLevel, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasTraceLevel(expected sdk.TraceLevel) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterStringUnderlyingValueSet(sdk.DatabaseParameterTraceLevel, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasSuspendTaskAfterNumFailures(expected int) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterIntValueSet(sdk.DatabaseParameterSuspendTaskAfterNumFailures, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasTaskAutoRetryAttempts(expected int) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterIntValueSet(sdk.DatabaseParameterTaskAutoRetryAttempts, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasUserTaskManagedInitialWarehouseSize(expected sdk.WarehouseSize) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterStringUnderlyingValueSet(sdk.DatabaseParameterUserTaskManagedInitialWarehouseSize, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasUserTaskTimeoutMs(expected int) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterIntValueSet(sdk.DatabaseParameterUserTaskTimeoutMs, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasUserTaskMinimumTriggerIntervalInSeconds(expected int) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterIntValueSet(sdk.DatabaseParameterUserTaskMinimumTriggerIntervalInSeconds, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasQuotedIdentifiersIgnoreCase(expected bool) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterBoolValueSet(sdk.DatabaseParameterQuotedIdentifiersIgnoreCase, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasEnableConsoleOutput(expected bool) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterBoolValueSet(sdk.DatabaseParameterEnableConsoleOutput, expected)) + return d +} + +//////////////////////////// +// Parameter level checks // +//////////////////////////// + +func (d *DatabaseParametersAssert) HasDataRetentionTimeInDaysLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterDataRetentionTimeInDays, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasMaxDataExtensionTimeInDaysLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterMaxDataExtensionTimeInDays, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasExternalVolumeLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterExternalVolume, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasCatalogLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterCatalog, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasReplaceInvalidCharactersLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterReplaceInvalidCharacters, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasDefaultDdlCollationLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterDefaultDdlCollation, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasStorageSerializationPolicyLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterStorageSerializationPolicy, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasLogLevelLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterLogLevel, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasTraceLevelLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterTraceLevel, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasSuspendTaskAfterNumFailuresLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterSuspendTaskAfterNumFailures, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasTaskAutoRetryAttemptsLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterTaskAutoRetryAttempts, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasUserTaskManagedInitialWarehouseSizeLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterUserTaskManagedInitialWarehouseSize, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasUserTaskTimeoutMsLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterUserTaskTimeoutMs, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasUserTaskMinimumTriggerIntervalInSecondsLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterUserTaskMinimumTriggerIntervalInSeconds, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasQuotedIdentifiersIgnoreCaseLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterQuotedIdentifiersIgnoreCase, expected)) + return d +} + +func (d *DatabaseParametersAssert) HasEnableConsoleOutputLevel(expected sdk.ParameterType) *DatabaseParametersAssert { + d.AddAssertion(assert.SnowflakeParameterLevelSet(sdk.DatabaseParameterEnableConsoleOutput, expected)) + return d +} + +//////////////////////////////////// +// Parameter default value checks // +//////////////////////////////////// + +func (d *DatabaseParametersAssert) HasDefaultDataRetentionTimeInDaysValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterDataRetentionTimeInDays) +} + +func (d *DatabaseParametersAssert) HasDefaultMaxDataExtensionTimeInDaysValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterMaxDataExtensionTimeInDays) +} + +func (d *DatabaseParametersAssert) HasDefaultExternalVolumeValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterExternalVolume) +} + +func (d *DatabaseParametersAssert) HasDefaultCatalogValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterCatalog) +} + +func (d *DatabaseParametersAssert) HasDefaultReplaceInvalidCharactersValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterReplaceInvalidCharacters) +} + +func (d *DatabaseParametersAssert) HasDefaultDefaultDdlCollationValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterDefaultDdlCollation) +} + +func (d *DatabaseParametersAssert) HasDefaultStorageSerializationPolicyValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterStorageSerializationPolicy) +} + +func (d *DatabaseParametersAssert) HasDefaultLogLevelValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterLogLevel) +} + +func (d *DatabaseParametersAssert) HasDefaultTraceLevelValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterTraceLevel) +} + +func (d *DatabaseParametersAssert) HasDefaultSuspendTaskAfterNumFailuresValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterSuspendTaskAfterNumFailures) +} + +func (d *DatabaseParametersAssert) HasDefaultTaskAutoRetryAttemptsValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterTaskAutoRetryAttempts) +} + +func (d *DatabaseParametersAssert) HasDefaultUserTaskManagedInitialWarehouseSizeValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterUserTaskManagedInitialWarehouseSize) +} + +func (d *DatabaseParametersAssert) HasDefaultUserTaskTimeoutMsValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterUserTaskTimeoutMs) +} + +func (d *DatabaseParametersAssert) HasDefaultUserTaskMinimumTriggerIntervalInSecondsValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterUserTaskMinimumTriggerIntervalInSeconds) +} + +func (d *DatabaseParametersAssert) HasDefaultQuotedIdentifiersIgnoreCaseValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterQuotedIdentifiersIgnoreCase) +} + +func (d *DatabaseParametersAssert) HasDefaultEnableConsoleOutputValue() *DatabaseParametersAssert { + return d.HasDefaultParameterValue(sdk.DatabaseParameterEnableConsoleOutput) +} + +///////////////////////////////////////////// +// Parameter explicit default value checks // +///////////////////////////////////////////// + +func (d *DatabaseParametersAssert) HasDefaultDataRetentionTimeInDaysValueExplicit() *DatabaseParametersAssert { + return d.HasDataRetentionTimeInDays(1) +} + +func (d *DatabaseParametersAssert) HasDefaultMaxDataExtensionTimeInDaysValueExplicit() *DatabaseParametersAssert { + return d.HasMaxDataExtensionTimeInDays(14) +} + +func (d *DatabaseParametersAssert) HasDefaultExternalVolumeValueExplicit() *DatabaseParametersAssert { + return d.HasExternalVolume("") +} + +func (d *DatabaseParametersAssert) HasDefaultCatalogValueExplicit() *DatabaseParametersAssert { + return d.HasCatalog("") +} + +func (d *DatabaseParametersAssert) HasDefaultReplaceInvalidCharactersValueExplicit() *DatabaseParametersAssert { + return d.HasReplaceInvalidCharacters(false) +} + +func (d *DatabaseParametersAssert) HasDefaultDefaultDdlCollationValueExplicit() *DatabaseParametersAssert { + return d.HasDefaultDdlCollation("") +} + +func (d *DatabaseParametersAssert) HasDefaultStorageSerializationPolicyValueExplicit() *DatabaseParametersAssert { + return d.HasStorageSerializationPolicy(sdk.StorageSerializationPolicyOptimized) +} + +func (d *DatabaseParametersAssert) HasDefaultLogLevelValueExplicit() *DatabaseParametersAssert { + return d.HasLogLevel(sdk.LogLevelOff) +} + +func (d *DatabaseParametersAssert) HasDefaultTraceLevelValueExplicit() *DatabaseParametersAssert { + return d.HasTraceLevel(sdk.TraceLevelOff) +} + +func (d *DatabaseParametersAssert) HasDefaultSuspendTaskAfterNumFailuresValueExplicit() *DatabaseParametersAssert { + return d.HasSuspendTaskAfterNumFailures(10) +} + +func (d *DatabaseParametersAssert) HasDefaultTaskAutoRetryAttemptsValueExplicit() *DatabaseParametersAssert { + return d.HasTaskAutoRetryAttempts(0) +} + +func (d *DatabaseParametersAssert) HasDefaultUserTaskManagedInitialWarehouseSizeValueExplicit() *DatabaseParametersAssert { + return d.HasUserTaskManagedInitialWarehouseSize(sdk.WarehouseSizeMedium) +} + +func (d *DatabaseParametersAssert) HasDefaultUserTaskTimeoutMsValueExplicit() *DatabaseParametersAssert { + return d.HasUserTaskTimeoutMs(3600000) +} + +func (d *DatabaseParametersAssert) HasDefaultUserTaskMinimumTriggerIntervalInSecondsValueExplicit() *DatabaseParametersAssert { + return d.HasUserTaskMinimumTriggerIntervalInSeconds(30) +} + +func (d *DatabaseParametersAssert) HasDefaultQuotedIdentifiersIgnoreCaseValueExplicit() *DatabaseParametersAssert { + return d.HasQuotedIdentifiersIgnoreCase(false) +} + +func (d *DatabaseParametersAssert) HasDefaultEnableConsoleOutputValueExplicit() *DatabaseParametersAssert { + return d.HasEnableConsoleOutput(false) +} diff --git a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/gen/object_parameters_def.go b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/gen/object_parameters_def.go index a4013bbad2..b87151ccae 100644 --- a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/gen/object_parameters_def.go +++ b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/gen/object_parameters_def.go @@ -105,4 +105,27 @@ var allObjectsParameters = []SnowflakeObjectParameters{ {ParameterName: string(sdk.WarehouseParameterStatementTimeoutInSeconds), ParameterType: "int", DefaultValue: "172800", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, }, }, + { + Name: "Database", + IdType: "sdk.AccountObjectIdentifier", + Level: sdk.ParameterTypeDatabase, + Parameters: []SnowflakeParameter{ + {ParameterName: string(sdk.DatabaseParameterDataRetentionTimeInDays), ParameterType: "int", DefaultValue: "1", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterMaxDataExtensionTimeInDays), ParameterType: "int", DefaultValue: "14", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterExternalVolume), ParameterType: "string", DefaultValue: "", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterCatalog), ParameterType: "string", DefaultValue: "", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterReplaceInvalidCharacters), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterDefaultDdlCollation), ParameterType: "string", DefaultValue: "", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterStorageSerializationPolicy), ParameterType: "sdk.StorageSerializationPolicy", DefaultValue: "sdk.StorageSerializationPolicyOptimized", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterLogLevel), ParameterType: "sdk.LogLevel", DefaultValue: "sdk.LogLevelOff", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterTraceLevel), ParameterType: "sdk.TraceLevel", DefaultValue: "sdk.TraceLevelOff", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterSuspendTaskAfterNumFailures), ParameterType: "int", DefaultValue: "10", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterTaskAutoRetryAttempts), ParameterType: "int", DefaultValue: "0", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterUserTaskManagedInitialWarehouseSize), ParameterType: "sdk.WarehouseSize", DefaultValue: "sdk.WarehouseSizeMedium", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterUserTaskTimeoutMs), ParameterType: "int", DefaultValue: "3600000", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterUserTaskMinimumTriggerIntervalInSeconds), ParameterType: "int", DefaultValue: "30", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + {ParameterName: string(sdk.DatabaseParameterQuotedIdentifiersIgnoreCase), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeAccount"}, + {ParameterName: string(sdk.DatabaseParameterEnableConsoleOutput), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, + }, + }, } diff --git a/pkg/acceptance/bettertestspoc/assert/snowflake_assertions.go b/pkg/acceptance/bettertestspoc/assert/snowflake_assertions.go index 401a1284fa..801c41aa0d 100644 --- a/pkg/acceptance/bettertestspoc/assert/snowflake_assertions.go +++ b/pkg/acceptance/bettertestspoc/assert/snowflake_assertions.go @@ -52,6 +52,10 @@ func (s *SnowflakeObjectAssert[T, I]) AddAssertion(assertion assertSdk[*T]) { s.assertions = append(s.assertions, assertion) } +func (s *SnowflakeObjectAssert[T, I]) GetId() I { + return s.id +} + // ToTerraformTestCheckFunc implements TestCheckFuncProvider to allow easier creation of new Snowflake object assertions. // It goes through all the assertion accumulated earlier and gathers the results of the checks. func (s *SnowflakeObjectAssert[_, _]) ToTerraformTestCheckFunc(t *testing.T) resource.TestCheckFunc { diff --git a/pkg/acceptance/helpers/database_client.go b/pkg/acceptance/helpers/database_client.go index e0dc584dfd..1011336f7a 100644 --- a/pkg/acceptance/helpers/database_client.go +++ b/pkg/acceptance/helpers/database_client.go @@ -147,12 +147,9 @@ func (c *DatabaseClient) Show(t *testing.T, id sdk.AccountObjectIdentifier) (*sd return c.client().ShowByID(ctx, id) } -func (c *DatabaseClient) Describe(t *testing.T, id sdk.AccountObjectIdentifier) *sdk.DatabaseDetails { +func (c *DatabaseClient) Describe(t *testing.T, id sdk.AccountObjectIdentifier) (*sdk.DatabaseDetails, error) { t.Helper() ctx := context.Background() - details, err := c.client().Describe(ctx, id) - require.NoError(t, err) - - return details + return c.client().Describe(ctx, id) } diff --git a/pkg/acceptance/snowflakechecks/database.go b/pkg/acceptance/snowflakechecks/database.go deleted file mode 100644 index d43601fa66..0000000000 --- a/pkg/acceptance/snowflakechecks/database.go +++ /dev/null @@ -1,49 +0,0 @@ -package snowflakechecks - -import ( - "errors" - "fmt" - "slices" - "testing" - - acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" -) - -func CheckDatabaseDataRetentionTimeInDays(t *testing.T, databaseId sdk.AccountObjectIdentifier, expectedLevel sdk.ParameterType, expectedValue string) resource.TestCheckFunc { - t.Helper() - return func(state *terraform.State) error { - param := helpers.FindParameter(t, acc.TestClient().Parameter.ShowDatabaseParameters(t, databaseId), sdk.AccountParameterDataRetentionTimeInDays) - var errs []error - if param.Level != expectedLevel { - errs = append(errs, fmt.Errorf("expected parameter level %s, got %s", expectedLevel, param.Level)) - } - if param.Value != expectedValue { - errs = append(errs, fmt.Errorf("expected parameter value %s, got %s", expectedLevel, param.Level)) - } - return errors.Join(errs...) - } -} - -func DoesNotContainPublicSchema(t *testing.T, id sdk.AccountObjectIdentifier) resource.TestCheckFunc { - t.Helper() - return func(state *terraform.State) error { - if slices.ContainsFunc(acc.TestClient().Database.Describe(t, id).Rows, func(row sdk.DatabaseDetailsRow) bool { return row.Name == "PUBLIC" && row.Kind == "SCHEMA" }) { - return fmt.Errorf("expected database %s to not contain public schema", id.FullyQualifiedName()) - } - return nil - } -} - -func ContainsPublicSchema(t *testing.T, id sdk.AccountObjectIdentifier) resource.TestCheckFunc { - t.Helper() - return func(state *terraform.State) error { - if !slices.ContainsFunc(acc.TestClient().Database.Describe(t, id).Rows, func(row sdk.DatabaseDetailsRow) bool { return row.Name == "PUBLIC" && row.Kind == "SCHEMA" }) { - return fmt.Errorf("expected database %s to contain public schema", id.FullyQualifiedName()) - } - return nil - } -} diff --git a/pkg/acceptance/snowflakechecks/warehouse.go b/pkg/acceptance/snowflakechecks/warehouse.go deleted file mode 100644 index e0be13e9d8..0000000000 --- a/pkg/acceptance/snowflakechecks/warehouse.go +++ /dev/null @@ -1,68 +0,0 @@ -package snowflakechecks - -import ( - "fmt" - "testing" - - acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" - - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/hashicorp/terraform-plugin-testing/terraform" -) - -// TODO [SNOW-1473412]: consider using size from state instead of passing it -func CheckWarehouseSize(t *testing.T, id sdk.AccountObjectIdentifier, expectedSize sdk.WarehouseSize) func(state *terraform.State) error { - t.Helper() - return func(_ *terraform.State) error { - warehouse, err := acc.TestClient().Warehouse.Show(t, id) - if err != nil { - return err - } - if warehouse.Size != expectedSize { - return fmt.Errorf("expected size: %s; got: %s", expectedSize, warehouse.Size) - } - return nil - } -} - -func CheckWarehouseType(t *testing.T, id sdk.AccountObjectIdentifier, expectedType sdk.WarehouseType) func(state *terraform.State) error { - t.Helper() - return func(_ *terraform.State) error { - warehouse, err := acc.TestClient().Warehouse.Show(t, id) - if err != nil { - return err - } - if warehouse.Type != expectedType { - return fmt.Errorf("expected type: %s; got: %s", expectedType, warehouse.Type) - } - return nil - } -} - -func CheckAutoResume(t *testing.T, id sdk.AccountObjectIdentifier, expectedAutoResume bool) func(state *terraform.State) error { - t.Helper() - return func(_ *terraform.State) error { - warehouse, err := acc.TestClient().Warehouse.Show(t, id) - if err != nil { - return err - } - if warehouse.AutoResume != expectedAutoResume { - return fmt.Errorf("expected auto resume: %t; got: %t", expectedAutoResume, warehouse.AutoResume) - } - return nil - } -} - -func CheckAutoSuspendCount(t *testing.T, id sdk.AccountObjectIdentifier, expectedAutoSuspend int) func(state *terraform.State) error { - t.Helper() - return func(_ *terraform.State) error { - warehouse, err := acc.TestClient().Warehouse.Show(t, id) - if err != nil { - return err - } - if warehouse.AutoSuspend != expectedAutoSuspend { - return fmt.Errorf("expected auto suspend: %d; got: %d", expectedAutoSuspend, warehouse.AutoSuspend) - } - return nil - } -} diff --git a/pkg/internal/genhelpers/struct_details_extractor.go b/pkg/internal/genhelpers/struct_details_extractor.go index ad84b97f5d..0b4baf2608 100644 --- a/pkg/internal/genhelpers/struct_details_extractor.go +++ b/pkg/internal/genhelpers/struct_details_extractor.go @@ -29,8 +29,13 @@ func (f *Field) IsSlice() bool { return strings.HasPrefix(f.ConcreteType, "[]") } +func (f *Field) ConcreteTypeNoPointer() string { + concreteTypeNoPtr, _ := strings.CutPrefix(f.ConcreteType, "*") + return concreteTypeNoPtr +} + func (f *Field) GetImportedType() (string, bool) { - parts := strings.Split(f.ConcreteType, ".") + parts := strings.Split(f.ConcreteTypeNoPointer(), ".") return parts[0], len(parts) > 1 } diff --git a/pkg/resources/alert_acceptance_test.go b/pkg/resources/alert_acceptance_test.go index e0356b6ec2..ec7b15c279 100644 --- a/pkg/resources/alert_acceptance_test.go +++ b/pkg/resources/alert_acceptance_test.go @@ -104,7 +104,7 @@ func TestAcc_Alert(t *testing.T) { { Config: alertConfig(alertInitialState), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_alert.test_alert", "enabled", alertInitialState.Alert.Enabled), + resource.TestCheckResourceAttr("snowflake_alert.test_alert", "enabled", strconv.FormatBool(alertInitialState.Alert.Enabled)), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "name", id.Name()), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "fully_qualified_name", id.FullyQualifiedName()), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "database", acc.TestDatabaseName), @@ -118,7 +118,7 @@ func TestAcc_Alert(t *testing.T) { { Config: alertConfig(alertStepOne), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_alert.test_alert", "enabled", alertStepOne.Alert.Enabled), + resource.TestCheckResourceAttr("snowflake_alert.test_alert", "enabled", strconv.FormatBool(alertStepOne.Alert.Enabled)), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "name", id.Name()), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "fully_qualified_name", id.FullyQualifiedName()), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "database", acc.TestDatabaseName), @@ -132,7 +132,7 @@ func TestAcc_Alert(t *testing.T) { { Config: alertConfig(alertStepTwo), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_alert.test_alert", "enabled", alertStepTwo.Alert.Enabled), + resource.TestCheckResourceAttr("snowflake_alert.test_alert", "enabled", strconv.FormatBool(alertStepTwo.Alert.Enabled)), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "name", id.Name()), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "fully_qualified_name", id.FullyQualifiedName()), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "database", acc.TestDatabaseName), @@ -146,7 +146,7 @@ func TestAcc_Alert(t *testing.T) { { Config: alertConfig(alertStepThree), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_alert.test_alert", "enabled", alertStepThree.Alert.Enabled), + resource.TestCheckResourceAttr("snowflake_alert.test_alert", "enabled", strconv.FormatBool(alertStepThree.Alert.Enabled)), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "name", id.Name()), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "fully_qualified_name", id.FullyQualifiedName()), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "database", acc.TestDatabaseName), @@ -160,7 +160,7 @@ func TestAcc_Alert(t *testing.T) { { Config: alertConfig(alertInitialState), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_alert.test_alert", "enabled", alertInitialState.Alert.Enabled), + resource.TestCheckResourceAttr("snowflake_alert.test_alert", "enabled", strconv.FormatBool(alertInitialState.Alert.Enabled)), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "name", id.Name()), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "fully_qualified_name", id.FullyQualifiedName()), resource.TestCheckResourceAttr("snowflake_alert.test_alert", "database", acc.TestDatabaseName), diff --git a/pkg/resources/database_acceptance_test.go b/pkg/resources/database_acceptance_test.go index 22bf3bb3eb..9debdb1a3a 100644 --- a/pkg/resources/database_acceptance_test.go +++ b/pkg/resources/database_acceptance_test.go @@ -5,17 +5,18 @@ import ( "strconv" "testing" - resourcehelpers "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers" - acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + resourcehelpers "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers" r "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources" tfjson "github.com/hashicorp/terraform-json" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert/objectassert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert/objectparametersassert" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/importchecks" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/planchecks" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/snowflakechecks" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" "github.com/hashicorp/terraform-plugin-testing/config" @@ -767,9 +768,9 @@ func TestAcc_Database_IntParameter(t *testing.T) { planchecks.ExpectComputed("snowflake_database.test", "data_retention_time_in_days", false), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "25"), - snowflakechecks.CheckDatabaseDataRetentionTimeInDays(t, id, sdk.ParameterTypeDatabase, "25"), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "25")), + objectparametersassert.DatabaseParameters(t, id).HasDataRetentionTimeInDays(25).HasDataRetentionTimeInDaysLevel(sdk.ParameterTypeDatabase), ), }, // remove the param from config @@ -787,9 +788,9 @@ func TestAcc_Database_IntParameter(t *testing.T) { planchecks.ExpectComputed("snowflake_database.test", "data_retention_time_in_days", true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "1"), - snowflakechecks.CheckDatabaseDataRetentionTimeInDays(t, id, "", "1"), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "1")), + objectparametersassert.DatabaseParameters(t, id).HasDataRetentionTimeInDays(1).HasDataRetentionTimeInDaysLevel(sdk.ParameterTypeSnowflakeDefault), ), }, // import when param not in config (snowflake default) @@ -812,9 +813,9 @@ func TestAcc_Database_IntParameter(t *testing.T) { planchecks.ExpectComputed("snowflake_database.test", "data_retention_time_in_days", true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "1"), - snowflakechecks.CheckDatabaseDataRetentionTimeInDays(t, id, sdk.ParameterTypeDatabase, "1"), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "1")), + objectparametersassert.DatabaseParameters(t, id).HasDataRetentionTimeInDays(25).HasDataRetentionTimeInDaysLevel(sdk.ParameterTypeDatabase), ), }, // remove the param from config @@ -832,9 +833,9 @@ func TestAcc_Database_IntParameter(t *testing.T) { planchecks.ExpectComputed("snowflake_database.test", "data_retention_time_in_days", true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "1"), // Database default - snowflakechecks.CheckDatabaseDataRetentionTimeInDays(t, id, "", "1"), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "1")), // Database default + objectparametersassert.DatabaseParameters(t, id).HasDataRetentionTimeInDays(1).HasDataRetentionTimeInDaysLevel(sdk.ParameterTypeSnowflakeDefault), ), }, // change param value on account - change expected to be noop @@ -855,9 +856,9 @@ func TestAcc_Database_IntParameter(t *testing.T) { planchecks.ExpectComputed("snowflake_database.test", "data_retention_time_in_days", false), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "50"), - snowflakechecks.CheckDatabaseDataRetentionTimeInDays(t, id, sdk.ParameterTypeAccount, "50"), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "50")), + objectparametersassert.DatabaseParameters(t, id).HasDataRetentionTimeInDays(50).HasDataRetentionTimeInDaysLevel(sdk.ParameterTypeAccount), ), }, // import when param not in config (set on account) @@ -868,8 +869,8 @@ func TestAcc_Database_IntParameter(t *testing.T) { ImportStateCheck: importchecks.ComposeImportStateCheck( importchecks.TestCheckResourceAttrInstanceState(resourcehelpers.EncodeResourceIdentifier(id), "data_retention_time_in_days", "50"), ), - Check: resource.ComposeTestCheckFunc( - snowflakechecks.CheckDatabaseDataRetentionTimeInDays(t, id, sdk.ParameterTypeAccount, "50"), + Check: assert.AssertThat(t, + objectparametersassert.DatabaseParameters(t, id).HasDataRetentionTimeInDays(50).HasDataRetentionTimeInDaysLevel(sdk.ParameterTypeAccount), ), }, // change param value on database @@ -886,9 +887,9 @@ func TestAcc_Database_IntParameter(t *testing.T) { planchecks.ExpectComputed("snowflake_database.test", "data_retention_time_in_days", true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "50"), - snowflakechecks.CheckDatabaseDataRetentionTimeInDays(t, id, sdk.ParameterTypeAccount, "50"), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "50")), + objectparametersassert.DatabaseParameters(t, id).HasDataRetentionTimeInDays(50).HasDataRetentionTimeInDaysLevel(sdk.ParameterTypeAccount), ), }, // unset param on account @@ -906,9 +907,9 @@ func TestAcc_Database_IntParameter(t *testing.T) { planchecks.ExpectComputed("snowflake_database.test", "data_retention_time_in_days", false), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "1"), - snowflakechecks.CheckDatabaseDataRetentionTimeInDays(t, id, "", "1"), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_database.test", "data_retention_time_in_days", "1")), + objectparametersassert.DatabaseParameters(t, id).HasDataRetentionTimeInDays(1).HasDataRetentionTimeInDaysLevel(sdk.ParameterTypeSnowflakeDefault), ), }, }, @@ -1189,9 +1190,9 @@ func TestAcc_Database_WithoutPublicSchema(t *testing.T) { Steps: []resource.TestStep{ { Config: databaseWithDropPublicSchemaConfig(id, true), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_database.test", "id", id.Name()), - snowflakechecks.DoesNotContainPublicSchema(t, id), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_database.test", "id", id.Name())), + objectassert.DatabaseDescribe(t, id).DoesNotContainPublicSchema(), ), }, // Change in parameter shouldn't change the state Snowflake @@ -1202,9 +1203,9 @@ func TestAcc_Database_WithoutPublicSchema(t *testing.T) { }, }, Config: databaseWithDropPublicSchemaConfig(id, false), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_database.test", "id", id.Name()), - snowflakechecks.DoesNotContainPublicSchema(t, id), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_database.test", "id", id.Name())), + objectassert.DatabaseDescribe(t, id).DoesNotContainPublicSchema(), ), }, }, @@ -1224,9 +1225,9 @@ func TestAcc_Database_WithPublicSchema(t *testing.T) { Steps: []resource.TestStep{ { Config: databaseWithDropPublicSchemaConfig(id, false), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_database.test", "id", id.Name()), - snowflakechecks.ContainsPublicSchema(t, id), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_database.test", "id", id.Name())), + objectassert.DatabaseDescribe(t, id).ContainsPublicSchema(), ), }, // Change in parameter shouldn't change the state Snowflake @@ -1237,9 +1238,9 @@ func TestAcc_Database_WithPublicSchema(t *testing.T) { }, }, Config: databaseWithDropPublicSchemaConfig(id, true), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_database.test", "id", id.Name()), - snowflakechecks.ContainsPublicSchema(t, id), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_database.test", "id", id.Name())), + objectassert.DatabaseDescribe(t, id).ContainsPublicSchema(), ), }, }, diff --git a/pkg/resources/deprecated_test.go b/pkg/resources/deprecated_test.go deleted file mode 100644 index 815237aef8..0000000000 --- a/pkg/resources/deprecated_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package resources_test - -import ( - "fmt" - "strconv" - - "github.com/hashicorp/terraform-plugin-testing/terraform" -) - -// checkBool is deprecated and will be removed with resources rework (and replaced with new assertions) -func checkBool(path, attr string, value bool) func(*terraform.State) error { - return func(state *terraform.State) error { - is := state.RootModule().Resources[path].Primary - d := is.Attributes[attr] - b, err := strconv.ParseBool(d) - if err != nil { - return err - } - if b != value { - return fmt.Errorf("at %s expected %t but got %t", path, value, b) - } - return nil - } -} diff --git a/pkg/resources/materialized_view_acceptance_test.go b/pkg/resources/materialized_view_acceptance_test.go index f77838c3a1..a2c271fb64 100644 --- a/pkg/resources/materialized_view_acceptance_test.go +++ b/pkg/resources/materialized_view_acceptance_test.go @@ -39,7 +39,7 @@ func TestAcc_MaterializedView(t *testing.T) { resource.TestCheckResourceAttr("snowflake_materialized_view.test", "schema", acc.TestSchemaName), resource.TestCheckResourceAttr("snowflake_materialized_view.test", "warehouse", acc.TestWarehouseName), resource.TestCheckResourceAttr("snowflake_materialized_view.test", "comment", "Terraform test resource"), - checkBool("snowflake_materialized_view.test", "is_secure", true), + resource.TestCheckResourceAttr("snowflake_materialized_view.test", "is_secure", "true"), ), }, // update parameters @@ -52,7 +52,7 @@ func TestAcc_MaterializedView(t *testing.T) { resource.TestCheckResourceAttr("snowflake_materialized_view.test", "schema", acc.TestSchemaName), resource.TestCheckResourceAttr("snowflake_materialized_view.test", "warehouse", acc.TestWarehouseName), resource.TestCheckResourceAttr("snowflake_materialized_view.test", "comment", "other comment"), - checkBool("snowflake_materialized_view.test", "is_secure", false), + resource.TestCheckResourceAttr("snowflake_materialized_view.test", "is_secure", "false"), ), }, // change statement @@ -65,7 +65,7 @@ func TestAcc_MaterializedView(t *testing.T) { resource.TestCheckResourceAttr("snowflake_materialized_view.test", "schema", acc.TestSchemaName), resource.TestCheckResourceAttr("snowflake_materialized_view.test", "warehouse", acc.TestWarehouseName), resource.TestCheckResourceAttr("snowflake_materialized_view.test", "comment", "other comment"), - checkBool("snowflake_materialized_view.test", "is_secure", false), + resource.TestCheckResourceAttr("snowflake_materialized_view.test", "is_secure", "false"), ), }, // change statement externally @@ -81,7 +81,7 @@ func TestAcc_MaterializedView(t *testing.T) { resource.TestCheckResourceAttr("snowflake_materialized_view.test", "schema", acc.TestSchemaName), resource.TestCheckResourceAttr("snowflake_materialized_view.test", "warehouse", acc.TestWarehouseName), resource.TestCheckResourceAttr("snowflake_materialized_view.test", "comment", "other comment"), - checkBool("snowflake_materialized_view.test", "is_secure", false), + resource.TestCheckResourceAttr("snowflake_materialized_view.test", "is_secure", "false"), ), }, // IMPORT diff --git a/pkg/resources/password_policy.go b/pkg/resources/password_policy.go index 6886353157..91ebb5b03b 100644 --- a/pkg/resources/password_policy.go +++ b/pkg/resources/password_policy.go @@ -223,37 +223,37 @@ func ReadPasswordPolicy(d *schema.ResourceData, meta interface{}) error { return err } - if err := setIntProperty(d, "min_length", passwordPolicyDetails.PasswordMinLength); err != nil { + if err := setFromIntProperty(d, "min_length", passwordPolicyDetails.PasswordMinLength); err != nil { return err } - if err := setIntProperty(d, "max_length", passwordPolicyDetails.PasswordMaxLength); err != nil { + if err := setFromIntProperty(d, "max_length", passwordPolicyDetails.PasswordMaxLength); err != nil { return err } - if err := setIntProperty(d, "min_upper_case_chars", passwordPolicyDetails.PasswordMinUpperCaseChars); err != nil { + if err := setFromIntProperty(d, "min_upper_case_chars", passwordPolicyDetails.PasswordMinUpperCaseChars); err != nil { return err } - if err := setIntProperty(d, "min_lower_case_chars", passwordPolicyDetails.PasswordMinLowerCaseChars); err != nil { + if err := setFromIntProperty(d, "min_lower_case_chars", passwordPolicyDetails.PasswordMinLowerCaseChars); err != nil { return err } - if err := setIntProperty(d, "min_numeric_chars", passwordPolicyDetails.PasswordMinNumericChars); err != nil { + if err := setFromIntProperty(d, "min_numeric_chars", passwordPolicyDetails.PasswordMinNumericChars); err != nil { return err } - if err := setIntProperty(d, "min_special_chars", passwordPolicyDetails.PasswordMinSpecialChars); err != nil { + if err := setFromIntProperty(d, "min_special_chars", passwordPolicyDetails.PasswordMinSpecialChars); err != nil { return err } - if err := setIntProperty(d, "min_age_days", passwordPolicyDetails.PasswordMinAgeDays); err != nil { + if err := setFromIntProperty(d, "min_age_days", passwordPolicyDetails.PasswordMinAgeDays); err != nil { return err } - if err := setIntProperty(d, "max_age_days", passwordPolicyDetails.PasswordMaxAgeDays); err != nil { + if err := setFromIntProperty(d, "max_age_days", passwordPolicyDetails.PasswordMaxAgeDays); err != nil { return err } - if err := setIntProperty(d, "max_retries", passwordPolicyDetails.PasswordMaxRetries); err != nil { + if err := setFromIntProperty(d, "max_retries", passwordPolicyDetails.PasswordMaxRetries); err != nil { return err } - if err := setIntProperty(d, "lockout_time_mins", passwordPolicyDetails.PasswordLockoutTimeMins); err != nil { + if err := setFromIntProperty(d, "lockout_time_mins", passwordPolicyDetails.PasswordLockoutTimeMins); err != nil { return err } - if err := setIntProperty(d, "history", passwordPolicyDetails.PasswordHistory); err != nil { + if err := setFromIntProperty(d, "history", passwordPolicyDetails.PasswordHistory); err != nil { return err } diff --git a/pkg/resources/resource_helpers_read.go b/pkg/resources/resource_helpers_read.go index b0862858ba..b8f94a1e63 100644 --- a/pkg/resources/resource_helpers_read.go +++ b/pkg/resources/resource_helpers_read.go @@ -5,8 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -// TODO [SNOW-1348101 - next PR]: rename all these methods to setFromXxxProperty -func setIntProperty(d *schema.ResourceData, key string, property *sdk.IntProperty) error { +func setFromIntProperty(d *schema.ResourceData, key string, property *sdk.IntProperty) error { if property != nil && property.Value != nil { if err := d.Set(key, *property.Value); err != nil { return err @@ -15,7 +14,7 @@ func setIntProperty(d *schema.ResourceData, key string, property *sdk.IntPropert return nil } -func setStringProperty(d *schema.ResourceData, key string, property *sdk.StringProperty) error { +func setFromStringProperty(d *schema.ResourceData, key string, property *sdk.StringProperty) error { if property != nil { if err := d.Set(key, property.Value); err != nil { return err @@ -24,7 +23,7 @@ func setStringProperty(d *schema.ResourceData, key string, property *sdk.StringP return nil } -func setStringPropertyIfNotEmpty(d *schema.ResourceData, key string, property *sdk.StringProperty) error { +func setFromStringPropertyIfNotEmpty(d *schema.ResourceData, key string, property *sdk.StringProperty) error { if property != nil && property.Value != "" { if err := d.Set(key, property.Value); err != nil { return err @@ -33,7 +32,7 @@ func setStringPropertyIfNotEmpty(d *schema.ResourceData, key string, property *s return nil } -func setBoolProperty(d *schema.ResourceData, key string, property *sdk.BoolProperty) error { +func setFromBoolProperty(d *schema.ResourceData, key string, property *sdk.BoolProperty) error { if property != nil { if err := d.Set(key, property.Value); err != nil { return err diff --git a/pkg/resources/stream_acceptance_test.go b/pkg/resources/stream_acceptance_test.go index 1fccdd2e23..151361ac20 100644 --- a/pkg/resources/stream_acceptance_test.go +++ b/pkg/resources/stream_acceptance_test.go @@ -50,9 +50,9 @@ func TestAcc_StreamCreateOnStage(t *testing.T) { resource.TestCheckResourceAttr("snowflake_stream.test_stream", "database", accName), resource.TestCheckResourceAttr("snowflake_stream.test_stream", "schema", accName), resource.TestCheckResourceAttr("snowflake_stream.test_stream", "comment", "Terraform acceptance test"), - checkBool("snowflake_stream.test_stream", "append_only", false), - checkBool("snowflake_stream.test_stream", "insert_only", false), - checkBool("snowflake_stream.test_stream", "show_initial_rows", false), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "append_only", "false"), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "insert_only", "false"), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "show_initial_rows", "false"), ), }, }, @@ -164,9 +164,9 @@ func TestAcc_Stream(t *testing.T) { resource.TestCheckResourceAttr("snowflake_stream.test_stream", "schema", accName), resource.TestCheckResourceAttr("snowflake_stream.test_stream", "on_table", fmt.Sprintf("%s.%s.%s", accName, accName, "STREAM_ON_TABLE")), resource.TestCheckResourceAttr("snowflake_stream.test_stream", "comment", "Terraform acceptance test"), - checkBool("snowflake_stream.test_stream", "append_only", false), - checkBool("snowflake_stream.test_stream", "insert_only", false), - checkBool("snowflake_stream.test_stream", "show_initial_rows", false), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "append_only", "false"), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "insert_only", "false"), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "show_initial_rows", "false"), ), }, { @@ -177,9 +177,9 @@ func TestAcc_Stream(t *testing.T) { resource.TestCheckResourceAttr("snowflake_stream.test_stream", "schema", accName), resource.TestCheckResourceAttr("snowflake_stream.test_stream", "on_table", fmt.Sprintf("%s.%s.%s", accName, accName, "STREAM_ON_TABLE")), resource.TestCheckResourceAttr("snowflake_stream.test_stream", "comment", "Terraform acceptance test"), - checkBool("snowflake_stream.test_stream", "append_only", true), - checkBool("snowflake_stream.test_stream", "insert_only", false), - checkBool("snowflake_stream.test_stream", "show_initial_rows", false), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "append_only", "true"), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "insert_only", "false"), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "show_initial_rows", "false"), ), }, { @@ -190,9 +190,9 @@ func TestAcc_Stream(t *testing.T) { resource.TestCheckResourceAttr("snowflake_stream.test_stream", "schema", accNameExternalTable), resource.TestCheckResourceAttr("snowflake_stream.test_stream", "on_table", fmt.Sprintf("%s.%s.%s", accNameExternalTable, accNameExternalTable, "STREAM_ON_EXTERNAL_TABLE")), resource.TestCheckResourceAttr("snowflake_stream.test_stream", "comment", "Terraform acceptance test"), - checkBool("snowflake_stream.test_stream", "append_only", false), - checkBool("snowflake_stream.test_stream", "insert_only", false), - checkBool("snowflake_stream.test_stream", "show_initial_rows", false), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "append_only", "false"), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "insert_only", "false"), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "show_initial_rows", "false"), ), }, { @@ -203,9 +203,9 @@ func TestAcc_Stream(t *testing.T) { resource.TestCheckResourceAttr("snowflake_stream.test_stream", "schema", accNameExternalTable), resource.TestCheckResourceAttr("snowflake_stream.test_stream", "on_table", fmt.Sprintf("%s.%s.%s", accNameExternalTable, accNameExternalTable, "STREAM_ON_EXTERNAL_TABLE")), resource.TestCheckResourceAttr("snowflake_stream.test_stream", "comment", "Terraform acceptance test"), - checkBool("snowflake_stream.test_stream", "append_only", false), - checkBool("snowflake_stream.test_stream", "insert_only", true), - checkBool("snowflake_stream.test_stream", "show_initial_rows", false), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "append_only", "false"), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "insert_only", "true"), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "show_initial_rows", "false"), ), }, { @@ -216,9 +216,9 @@ func TestAcc_Stream(t *testing.T) { resource.TestCheckResourceAttr("snowflake_stream.test_stream", "schema", accName), resource.TestCheckResourceAttr("snowflake_stream.test_stream", "on_view", fmt.Sprintf("%s.%s.%s", accName, accName, "STREAM_ON_VIEW")), resource.TestCheckResourceAttr("snowflake_stream.test_stream", "comment", "Terraform acceptance test"), - checkBool("snowflake_stream.test_stream", "append_only", false), - checkBool("snowflake_stream.test_stream", "insert_only", false), - checkBool("snowflake_stream.test_stream", "show_initial_rows", false), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "append_only", "false"), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "insert_only", "false"), + resource.TestCheckResourceAttr("snowflake_stream.test_stream", "show_initial_rows", "false"), ), }, { diff --git a/pkg/resources/task_acceptance_test.go b/pkg/resources/task_acceptance_test.go index 03b3b21255..05ffa51176 100644 --- a/pkg/resources/task_acceptance_test.go +++ b/pkg/resources/task_acceptance_test.go @@ -203,8 +203,8 @@ func TestAcc_Task(t *testing.T) { { Config: taskConfig(initialState), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.root_task", "enabled", true), - checkBool("snowflake_task.child_task", "enabled", false), + resource.TestCheckResourceAttr("snowflake_task.root_task", "enabled", "true"), + resource.TestCheckResourceAttr("snowflake_task.child_task", "enabled", "false"), resource.TestCheckResourceAttr("snowflake_task.root_task", "name", rootname), resource.TestCheckResourceAttr("snowflake_task.root_task", "fully_qualified_name", rootId.FullyQualifiedName()), resource.TestCheckResourceAttr("snowflake_task.child_task", "name", childname), @@ -222,15 +222,15 @@ func TestAcc_Task(t *testing.T) { checkInt64("snowflake_task.root_task", "user_task_timeout_ms", initialState.RootTask.UserTaskTimeoutMs), resource.TestCheckNoResourceAttr("snowflake_task.solo_task", "user_task_timeout_ms"), checkInt64("snowflake_task.root_task", "session_parameters.LOCK_TIMEOUT", 1000), - checkBool("snowflake_task.root_task", "session_parameters.STRICT_JSON_OUTPUT", true), + resource.TestCheckResourceAttr("snowflake_task.root_task", "session_parameters.STRICT_JSON_OUTPUT", "true"), resource.TestCheckNoResourceAttr("snowflake_task.root_task", "session_parameters.MULTI_STATEMENT_COUNT"), ), }, { Config: taskConfig(stepOne), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.root_task", "enabled", true), - checkBool("snowflake_task.child_task", "enabled", true), + resource.TestCheckResourceAttr("snowflake_task.root_task", "enabled", "true"), + resource.TestCheckResourceAttr("snowflake_task.child_task", "enabled", "true"), resource.TestCheckResourceAttr("snowflake_task.root_task", "name", rootname), resource.TestCheckResourceAttr("snowflake_task.root_task", "fully_qualified_name", rootId.FullyQualifiedName()), resource.TestCheckResourceAttr("snowflake_task.child_task", "name", childname), @@ -247,15 +247,15 @@ func TestAcc_Task(t *testing.T) { checkInt64("snowflake_task.root_task", "user_task_timeout_ms", stepOne.RootTask.UserTaskTimeoutMs), checkInt64("snowflake_task.solo_task", "user_task_timeout_ms", stepOne.SoloTask.UserTaskTimeoutMs), checkInt64("snowflake_task.root_task", "session_parameters.LOCK_TIMEOUT", 1000), - checkBool("snowflake_task.root_task", "session_parameters.STRICT_JSON_OUTPUT", true), + resource.TestCheckResourceAttr("snowflake_task.root_task", "session_parameters.STRICT_JSON_OUTPUT", "true"), resource.TestCheckNoResourceAttr("snowflake_task.root_task", "session_parameters.MULTI_STATEMENT_COUNT"), ), }, { Config: taskConfig(stepTwo), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.root_task", "enabled", true), - checkBool("snowflake_task.child_task", "enabled", true), + resource.TestCheckResourceAttr("snowflake_task.root_task", "enabled", "true"), + resource.TestCheckResourceAttr("snowflake_task.child_task", "enabled", "true"), resource.TestCheckResourceAttr("snowflake_task.root_task", "name", rootname), resource.TestCheckResourceAttr("snowflake_task.root_task", "fully_qualified_name", rootId.FullyQualifiedName()), resource.TestCheckResourceAttr("snowflake_task.child_task", "name", childname), @@ -272,15 +272,15 @@ func TestAcc_Task(t *testing.T) { checkInt64("snowflake_task.root_task", "user_task_timeout_ms", stepTwo.RootTask.UserTaskTimeoutMs), checkInt64("snowflake_task.solo_task", "user_task_timeout_ms", stepTwo.SoloTask.UserTaskTimeoutMs), checkInt64("snowflake_task.root_task", "session_parameters.LOCK_TIMEOUT", 1000), - checkBool("snowflake_task.root_task", "session_parameters.STRICT_JSON_OUTPUT", true), + resource.TestCheckResourceAttr("snowflake_task.root_task", "session_parameters.STRICT_JSON_OUTPUT", "true"), resource.TestCheckNoResourceAttr("snowflake_task.root_task", "session_parameters.MULTI_STATEMENT_COUNT"), ), }, { Config: taskConfig(stepThree), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.root_task", "enabled", false), - checkBool("snowflake_task.child_task", "enabled", false), + resource.TestCheckResourceAttr("snowflake_task.root_task", "enabled", "false"), + resource.TestCheckResourceAttr("snowflake_task.child_task", "enabled", "false"), resource.TestCheckResourceAttr("snowflake_task.root_task", "name", rootname), resource.TestCheckResourceAttr("snowflake_task.root_task", "fully_qualified_name", rootId.FullyQualifiedName()), resource.TestCheckResourceAttr("snowflake_task.child_task", "name", childname), @@ -304,8 +304,8 @@ func TestAcc_Task(t *testing.T) { { Config: taskConfig(initialState), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.root_task", "enabled", true), - checkBool("snowflake_task.child_task", "enabled", false), + resource.TestCheckResourceAttr("snowflake_task.root_task", "enabled", "true"), + resource.TestCheckResourceAttr("snowflake_task.child_task", "enabled", "false"), resource.TestCheckResourceAttr("snowflake_task.root_task", "name", rootname), resource.TestCheckResourceAttr("snowflake_task.root_task", "fully_qualified_name", rootId.FullyQualifiedName()), resource.TestCheckResourceAttr("snowflake_task.child_task", "name", childname), @@ -328,7 +328,7 @@ func TestAcc_Task(t *testing.T) { // USER_TASK_TIMEOUT_MS session variable. checkInt64("snowflake_task.solo_task", "user_task_timeout_ms", initialState.ChildTask.UserTaskTimeoutMs), checkInt64("snowflake_task.root_task", "session_parameters.LOCK_TIMEOUT", 1000), - checkBool("snowflake_task.root_task", "session_parameters.STRICT_JSON_OUTPUT", true), + resource.TestCheckResourceAttr("snowflake_task.root_task", "session_parameters.STRICT_JSON_OUTPUT", "true"), resource.TestCheckNoResourceAttr("snowflake_task.root_task", "session_parameters.MULTI_STATEMENT_COUNT"), ), }, @@ -571,7 +571,7 @@ func TestAcc_Task_SwitchScheduled(t *testing.T) { { Config: taskConfigManagedScheduled(accName, taskRootName, acc.TestDatabaseName, acc.TestSchemaName), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.test_task", "enabled", true), + resource.TestCheckResourceAttr("snowflake_task.test_task", "enabled", "true"), resource.TestCheckResourceAttr("snowflake_task.test_task", "database", acc.TestDatabaseName), resource.TestCheckResourceAttr("snowflake_task.test_task", "schema", acc.TestSchemaName), resource.TestCheckResourceAttr("snowflake_task.test_task", "sql_statement", "SELECT 1"), @@ -582,7 +582,7 @@ func TestAcc_Task_SwitchScheduled(t *testing.T) { { Config: taskConfigManagedScheduled2(accName, taskRootName, acc.TestDatabaseName, acc.TestSchemaName), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.test_task", "enabled", true), + resource.TestCheckResourceAttr("snowflake_task.test_task", "enabled", "true"), resource.TestCheckResourceAttr("snowflake_task.test_task", "database", acc.TestDatabaseName), resource.TestCheckResourceAttr("snowflake_task.test_task", "schema", acc.TestSchemaName), resource.TestCheckResourceAttr("snowflake_task.test_task", "sql_statement", "SELECT 1"), @@ -593,7 +593,7 @@ func TestAcc_Task_SwitchScheduled(t *testing.T) { { Config: taskConfigManagedScheduled(accName, taskRootName, acc.TestDatabaseName, acc.TestSchemaName), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.test_task", "enabled", true), + resource.TestCheckResourceAttr("snowflake_task.test_task", "enabled", "true"), resource.TestCheckResourceAttr("snowflake_task.test_task", "database", acc.TestDatabaseName), resource.TestCheckResourceAttr("snowflake_task.test_task", "schema", acc.TestSchemaName), resource.TestCheckResourceAttr("snowflake_task.test_task", "sql_statement", "SELECT 1"), @@ -604,7 +604,7 @@ func TestAcc_Task_SwitchScheduled(t *testing.T) { { Config: taskConfigManagedScheduled3(accName, taskRootName, acc.TestDatabaseName, acc.TestSchemaName), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.test_task", "enabled", false), + resource.TestCheckResourceAttr("snowflake_task.test_task", "enabled", "false"), resource.TestCheckResourceAttr("snowflake_task.test_task", "database", acc.TestDatabaseName), resource.TestCheckResourceAttr("snowflake_task.test_task", "schema", acc.TestSchemaName), resource.TestCheckResourceAttr("snowflake_task.test_task", "sql_statement", "SELECT 1"), @@ -722,8 +722,8 @@ func TestAcc_Task_issue2207(t *testing.T) { ConfigDirectory: config.TestStepDirectory(), ConfigVariables: m(), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.root_task", "enabled", true), - checkBool("snowflake_task.child_task", "enabled", true), + resource.TestCheckResourceAttr("snowflake_task.root_task", "enabled", "true"), + resource.TestCheckResourceAttr("snowflake_task.child_task", "enabled", "true"), ), ConfigPlanChecks: resource.ConfigPlanChecks{ PostApplyPostRefresh: []plancheck.PlanCheck{ @@ -736,8 +736,8 @@ func TestAcc_Task_issue2207(t *testing.T) { ConfigDirectory: acc.ConfigurationSameAsStepN(1), ConfigVariables: m2, Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.root_task", "enabled", true), - checkBool("snowflake_task.child_task", "enabled", true), + resource.TestCheckResourceAttr("snowflake_task.root_task", "enabled", "true"), + resource.TestCheckResourceAttr("snowflake_task.child_task", "enabled", "true"), ), }, }, @@ -769,7 +769,7 @@ func TestAcc_Task_issue2036(t *testing.T) { ConfigDirectory: config.TestStepDirectory(), ConfigVariables: m(), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.test_task", "enabled", true), + resource.TestCheckResourceAttr("snowflake_task.test_task", "enabled", "true"), resource.TestCheckResourceAttr("snowflake_task.test_task", "when", ""), ), }, @@ -778,7 +778,7 @@ func TestAcc_Task_issue2036(t *testing.T) { ConfigDirectory: config.TestStepDirectory(), ConfigVariables: m(), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.test_task", "enabled", true), + resource.TestCheckResourceAttr("snowflake_task.test_task", "enabled", "true"), resource.TestCheckResourceAttr("snowflake_task.test_task", "when", "TRUE"), ), }, @@ -787,7 +787,7 @@ func TestAcc_Task_issue2036(t *testing.T) { ConfigDirectory: acc.ConfigurationSameAsStepN(1), ConfigVariables: m(), Check: resource.ComposeTestCheckFunc( - checkBool("snowflake_task.test_task", "enabled", true), + resource.TestCheckResourceAttr("snowflake_task.test_task", "enabled", "true"), resource.TestCheckResourceAttr("snowflake_task.test_task", "when", ""), ), }, diff --git a/pkg/resources/user.go b/pkg/resources/user.go index 6c1bef83ee..05108193e4 100644 --- a/pkg/resources/user.go +++ b/pkg/resources/user.go @@ -233,9 +233,9 @@ func ImportUser(ctx context.Context, d *schema.ResourceData, meta any) ([]*schem err = errors.Join( d.Set("name", id.Name()), - setStringPropertyIfNotEmpty(d, "login_name", userDetails.LoginName), - setStringPropertyIfNotEmpty(d, "display_name", userDetails.DisplayName), - setStringPropertyIfNotEmpty(d, "default_namespace", userDetails.DefaultNamespace), + setFromStringPropertyIfNotEmpty(d, "login_name", userDetails.LoginName), + setFromStringPropertyIfNotEmpty(d, "display_name", userDetails.DisplayName), + setFromStringPropertyIfNotEmpty(d, "default_namespace", userDetails.DefaultNamespace), setBooleanStringFromBoolProperty(d, "must_change_password", userDetails.MustChangePassword), setBooleanStringFromBoolProperty(d, "disabled", userDetails.Disabled), // all others are set in read @@ -393,22 +393,22 @@ func GetReadUserFunc(withExternalChangesMarking bool) schema.ReadContextFunc { // can't read password // not reading login_name on purpose (handled as external change to show output) // not reading display_name on purpose (handled as external change to show output) - setStringPropertyIfNotEmpty(d, "first_name", userDetails.FirstName), - setStringPropertyIfNotEmpty(d, "middle_name", userDetails.MiddleName), - setStringPropertyIfNotEmpty(d, "last_name", userDetails.LastName), - setStringPropertyIfNotEmpty(d, "email", userDetails.Email), + setFromStringPropertyIfNotEmpty(d, "first_name", userDetails.FirstName), + setFromStringPropertyIfNotEmpty(d, "middle_name", userDetails.MiddleName), + setFromStringPropertyIfNotEmpty(d, "last_name", userDetails.LastName), + setFromStringPropertyIfNotEmpty(d, "email", userDetails.Email), // not reading must_change_password on purpose (handled as external change to show output) // not reading disabled on purpose (handled as external change to show output) // not reading days_to_expiry on purpose (they always change) // not reading mins_to_unlock on purpose (they always change) - setStringPropertyIfNotEmpty(d, "default_warehouse", userDetails.DefaultWarehouse), + setFromStringPropertyIfNotEmpty(d, "default_warehouse", userDetails.DefaultWarehouse), // not reading default_namespace because one-part namespace seems to be capitalized on Snowflake side (handled as external change to show output) - setStringPropertyIfNotEmpty(d, "default_role", userDetails.DefaultRole), + setFromStringPropertyIfNotEmpty(d, "default_role", userDetails.DefaultRole), d.Set("default_secondary_roles", defaultSecondaryRoles), // not reading mins_to_bypass_mfa on purpose (they always change) - setStringPropertyIfNotEmpty(d, "rsa_public_key", userDetails.RsaPublicKey), - setStringPropertyIfNotEmpty(d, "rsa_public_key_2", userDetails.RsaPublicKey2), - setStringPropertyIfNotEmpty(d, "comment", userDetails.Comment), + setFromStringPropertyIfNotEmpty(d, "rsa_public_key", userDetails.RsaPublicKey), + setFromStringPropertyIfNotEmpty(d, "rsa_public_key_2", userDetails.RsaPublicKey2), + setFromStringPropertyIfNotEmpty(d, "comment", userDetails.Comment), // can't read disable_mfa d.Set("user_type", u.Type), diff --git a/pkg/resources/view_acceptance_test.go b/pkg/resources/view_acceptance_test.go index 8c5cd24590..f8d65dfb74 100644 --- a/pkg/resources/view_acceptance_test.go +++ b/pkg/resources/view_acceptance_test.go @@ -637,7 +637,7 @@ func TestAcc_ViewChangeCopyGrants(t *testing.T) { resource.TestCheckResourceAttr("snowflake_view.test", "name", id.Name()), resource.TestCheckResourceAttr("snowflake_view.test", "database", id.DatabaseName()), resource.TestCheckResourceAttr("snowflake_view.test", "copy_grants", "false"), - checkBool("snowflake_view.test", "is_secure", true), + resource.TestCheckResourceAttr("snowflake_view.test", "is_secure", "true"), resource.TestCheckResourceAttr("snowflake_view.test", "show_output.#", "1"), resource.TestCheckResourceAttrWith("snowflake_view.test", "show_output.0.created_on", func(value string) error { createdOn = value @@ -656,7 +656,7 @@ func TestAcc_ViewChangeCopyGrants(t *testing.T) { } return nil }), - checkBool("snowflake_view.test", "is_secure", true), + resource.TestCheckResourceAttr("snowflake_view.test", "is_secure", "true"), ), }, }, @@ -688,7 +688,7 @@ func TestAcc_ViewChangeCopyGrantsReversed(t *testing.T) { createdOn = value return nil }), - checkBool("snowflake_view.test", "is_secure", true), + resource.TestCheckResourceAttr("snowflake_view.test", "is_secure", "true"), ), }, { @@ -701,7 +701,7 @@ func TestAcc_ViewChangeCopyGrantsReversed(t *testing.T) { } return nil }), - checkBool("snowflake_view.test", "is_secure", true), + resource.TestCheckResourceAttr("snowflake_view.test", "is_secure", "true"), ), }, }, diff --git a/pkg/resources/warehouse_acceptance_test.go b/pkg/resources/warehouse_acceptance_test.go index fe31c9c29a..3e96684a7b 100644 --- a/pkg/resources/warehouse_acceptance_test.go +++ b/pkg/resources/warehouse_acceptance_test.go @@ -23,7 +23,6 @@ import ( "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/importchecks" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/planchecks" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/snowflakechecks" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" @@ -365,11 +364,11 @@ func TestAcc_Warehouse_WarehouseType(t *testing.T) { }, }, Config: warehouseWithTypeConfig(id.Name(), sdk.WarehouseTypeStandard, sdk.WarehouseSizeMedium), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_type", string(sdk.WarehouseTypeStandard)), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.type", string(sdk.WarehouseTypeStandard)), - snowflakechecks.CheckWarehouseType(t, id, sdk.WarehouseTypeStandard), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_type", string(sdk.WarehouseTypeStandard))), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.type", string(sdk.WarehouseTypeStandard))), + objectassert.Warehouse(t, id).HasType(sdk.WarehouseTypeStandard), ), }, // import when type in config @@ -393,11 +392,11 @@ func TestAcc_Warehouse_WarehouseType(t *testing.T) { }, }, Config: warehouseWithTypeConfig(id.Name(), sdk.WarehouseTypeSnowparkOptimized, sdk.WarehouseSizeMedium), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_type", string(sdk.WarehouseTypeSnowparkOptimized)), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.type", string(sdk.WarehouseTypeSnowparkOptimized)), - snowflakechecks.CheckWarehouseType(t, id, sdk.WarehouseTypeSnowparkOptimized), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_type", string(sdk.WarehouseTypeSnowparkOptimized))), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.type", string(sdk.WarehouseTypeSnowparkOptimized))), + objectassert.Warehouse(t, id).HasType(sdk.WarehouseTypeSnowparkOptimized), ), }, // remove type from config @@ -411,11 +410,11 @@ func TestAcc_Warehouse_WarehouseType(t *testing.T) { planchecks.ExpectComputed("snowflake_warehouse.w", r.ShowOutputAttributeName, true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_type", ""), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.type", string(sdk.WarehouseTypeStandard)), - snowflakechecks.CheckWarehouseType(t, id, sdk.WarehouseTypeStandard), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_type", "")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.type", string(sdk.WarehouseTypeStandard))), + objectassert.Warehouse(t, id).HasType(sdk.WarehouseTypeStandard), ), }, // add config (lower case) @@ -428,11 +427,11 @@ func TestAcc_Warehouse_WarehouseType(t *testing.T) { }, }, Config: warehouseWithTypeConfig(id.Name(), sdk.WarehouseType(strings.ToLower(string(sdk.WarehouseTypeSnowparkOptimized))), sdk.WarehouseSizeMedium), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_type", strings.ToLower(string(sdk.WarehouseTypeSnowparkOptimized))), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.type", string(sdk.WarehouseTypeSnowparkOptimized)), - snowflakechecks.CheckWarehouseType(t, id, sdk.WarehouseTypeSnowparkOptimized), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_type", strings.ToLower(string(sdk.WarehouseTypeSnowparkOptimized)))), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.type", string(sdk.WarehouseTypeSnowparkOptimized))), + objectassert.Warehouse(t, id).HasType(sdk.WarehouseTypeSnowparkOptimized), ), }, // remove type from config but update warehouse externally to default (still expecting non-empty plan because we do not know the default) @@ -451,11 +450,11 @@ func TestAcc_Warehouse_WarehouseType(t *testing.T) { planchecks.ExpectComputed("snowflake_warehouse.w", r.ShowOutputAttributeName, true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_type", ""), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.type", string(sdk.WarehouseTypeStandard)), - snowflakechecks.CheckWarehouseType(t, id, sdk.WarehouseTypeStandard), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_type", "")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.type", string(sdk.WarehouseTypeStandard))), + objectassert.Warehouse(t, id).HasType(sdk.WarehouseTypeStandard), ), }, // change the size externally @@ -475,11 +474,11 @@ func TestAcc_Warehouse_WarehouseType(t *testing.T) { planchecks.ExpectComputed("snowflake_warehouse.w", r.ShowOutputAttributeName, true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_type", ""), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.type", string(sdk.WarehouseTypeStandard)), - snowflakechecks.CheckWarehouseType(t, id, sdk.WarehouseTypeStandard), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_type", "")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.type", string(sdk.WarehouseTypeStandard))), + objectassert.Warehouse(t, id).HasType(sdk.WarehouseTypeStandard), ), }, // import when no type in config @@ -518,11 +517,11 @@ func TestAcc_Warehouse_WarehouseSizes(t *testing.T) { }, }, Config: warehouseWithSizeConfig(id.Name(), string(sdk.WarehouseSizeSmall)), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_size", string(sdk.WarehouseSizeSmall)), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.size", string(sdk.WarehouseSizeSmall)), - snowflakechecks.CheckWarehouseSize(t, id, sdk.WarehouseSizeSmall), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_size", string(sdk.WarehouseSizeSmall))), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.size", string(sdk.WarehouseSizeSmall))), + objectassert.Warehouse(t, id).HasSize(sdk.WarehouseSizeSmall), ), }, // import when size in config @@ -546,11 +545,11 @@ func TestAcc_Warehouse_WarehouseSizes(t *testing.T) { }, }, Config: warehouseWithSizeConfig(id.Name(), string(sdk.WarehouseSizeMedium)), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_size", string(sdk.WarehouseSizeMedium)), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.size", string(sdk.WarehouseSizeMedium)), - snowflakechecks.CheckWarehouseSize(t, id, sdk.WarehouseSizeMedium), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_size", string(sdk.WarehouseSizeMedium))), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.size", string(sdk.WarehouseSizeMedium))), + objectassert.Warehouse(t, id).HasSize(sdk.WarehouseSizeMedium), ), }, // remove size from config @@ -564,11 +563,11 @@ func TestAcc_Warehouse_WarehouseSizes(t *testing.T) { planchecks.ExpectComputed("snowflake_warehouse.w", r.ShowOutputAttributeName, true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckNoResourceAttr("snowflake_warehouse.w", "warehouse_size"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.size", string(sdk.WarehouseSizeXSmall)), - snowflakechecks.CheckWarehouseSize(t, id, sdk.WarehouseSizeXSmall), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckNoResourceAttr("snowflake_warehouse.w", "warehouse_size")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.size", string(sdk.WarehouseSizeXSmall))), + objectassert.Warehouse(t, id).HasSize(sdk.WarehouseSizeXSmall), ), }, // add config (lower case) @@ -581,11 +580,11 @@ func TestAcc_Warehouse_WarehouseSizes(t *testing.T) { }, }, Config: warehouseWithSizeConfig(id.Name(), strings.ToLower(string(sdk.WarehouseSizeSmall))), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_size", strings.ToLower(string(sdk.WarehouseSizeSmall))), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.size", string(sdk.WarehouseSizeSmall)), - snowflakechecks.CheckWarehouseSize(t, id, sdk.WarehouseSizeSmall), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "warehouse_size", strings.ToLower(string(sdk.WarehouseSizeSmall)))), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.size", string(sdk.WarehouseSizeSmall))), + objectassert.Warehouse(t, id).HasSize(sdk.WarehouseSizeSmall), ), }, // remove size from config but update warehouse externally to default (still expecting non-empty plan because we do not know the default) @@ -604,11 +603,11 @@ func TestAcc_Warehouse_WarehouseSizes(t *testing.T) { planchecks.ExpectComputed("snowflake_warehouse.w", r.ShowOutputAttributeName, true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckNoResourceAttr("snowflake_warehouse.w", "warehouse_size"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.size", string(sdk.WarehouseSizeXSmall)), - snowflakechecks.CheckWarehouseSize(t, id, sdk.WarehouseSizeXSmall), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckNoResourceAttr("snowflake_warehouse.w", "warehouse_size")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.size", string(sdk.WarehouseSizeXSmall))), + objectassert.Warehouse(t, id).HasSize(sdk.WarehouseSizeXSmall), ), }, // change the size externally @@ -628,11 +627,11 @@ func TestAcc_Warehouse_WarehouseSizes(t *testing.T) { planchecks.ExpectComputed("snowflake_warehouse.w", r.ShowOutputAttributeName, true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckNoResourceAttr("snowflake_warehouse.w", "warehouse_size"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.size", string(sdk.WarehouseSizeXSmall)), - snowflakechecks.CheckWarehouseSize(t, id, sdk.WarehouseSizeXSmall), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckNoResourceAttr("snowflake_warehouse.w", "warehouse_size")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.size", string(sdk.WarehouseSizeXSmall))), + objectassert.Warehouse(t, id).HasSize(sdk.WarehouseSizeXSmall), ), }, // import when no size in config @@ -770,11 +769,11 @@ func TestAcc_Warehouse_AutoResume(t *testing.T) { }, }, Config: warehouseWithAutoResumeConfig(id.Name(), "true"), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_resume", "true"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_resume", "true"), - snowflakechecks.CheckAutoResume(t, id, true), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_resume", "true")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_resume", "true")), + objectassert.Warehouse(t, id).HasAutoResume(true), ), }, // import when type in config @@ -798,11 +797,11 @@ func TestAcc_Warehouse_AutoResume(t *testing.T) { }, }, Config: warehouseWithAutoResumeConfig(id.Name(), "false"), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_resume", "false"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_resume", "false"), - snowflakechecks.CheckAutoResume(t, id, false), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_resume", "false")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_resume", "false")), + objectassert.Warehouse(t, id).HasAutoResume(false), ), }, // remove type from config (expecting non-empty plan because we do not know the default) @@ -816,11 +815,11 @@ func TestAcc_Warehouse_AutoResume(t *testing.T) { planchecks.ExpectComputed("snowflake_warehouse.w", r.ShowOutputAttributeName, true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_resume", r.BooleanDefault), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_resume", "true"), - snowflakechecks.CheckAutoResume(t, id, true), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_resume", r.BooleanDefault)), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_resume", "true")), + objectassert.Warehouse(t, id).HasAutoResume(true), ), }, // change auto resume externally @@ -840,11 +839,11 @@ func TestAcc_Warehouse_AutoResume(t *testing.T) { planchecks.ExpectComputed("snowflake_warehouse.w", r.ShowOutputAttributeName, true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_resume", r.BooleanDefault), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_resume", "true"), - snowflakechecks.CheckWarehouseType(t, id, sdk.WarehouseTypeStandard), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_resume", r.BooleanDefault)), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_resume", "true")), + objectassert.Warehouse(t, id).HasType(sdk.WarehouseTypeStandard), ), }, // import when no type in config @@ -884,11 +883,11 @@ func TestAcc_Warehouse_AutoSuspend(t *testing.T) { }, }, Config: warehouseConfigWithAutoSuspend(id.Name(), 1200), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_suspend", "1200"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_suspend", "1200"), - snowflakechecks.CheckAutoSuspendCount(t, id, 1200), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_suspend", "1200")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_suspend", "1200")), + objectassert.Warehouse(t, id).HasAutoSuspend(1200), ), }, // import when auto suspend in config @@ -912,11 +911,11 @@ func TestAcc_Warehouse_AutoSuspend(t *testing.T) { }, }, Config: warehouseConfigWithAutoSuspend(id.Name(), 600), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_suspend", "600"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_suspend", "600"), - snowflakechecks.CheckAutoSuspendCount(t, id, 600), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_suspend", "600")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_suspend", "600")), + objectassert.Warehouse(t, id).HasAutoSuspend(600), ), }, // remove auto suspend from config (expecting non-empty plan because we do not know the default) @@ -930,11 +929,11 @@ func TestAcc_Warehouse_AutoSuspend(t *testing.T) { planchecks.ExpectComputed("snowflake_warehouse.w", r.ShowOutputAttributeName, true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_suspend", r.IntDefaultString), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_suspend", "600"), - snowflakechecks.CheckAutoSuspendCount(t, id, 600), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_suspend", r.IntDefaultString)), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_suspend", "600")), + objectassert.Warehouse(t, id).HasAutoSuspend(600), ), }, // change auto suspend externally @@ -954,11 +953,11 @@ func TestAcc_Warehouse_AutoSuspend(t *testing.T) { planchecks.ExpectComputed("snowflake_warehouse.w", r.ShowOutputAttributeName, true), }, }, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_suspend", r.IntDefaultString), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1"), - resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_suspend", "600"), - snowflakechecks.CheckAutoSuspendCount(t, id, 600), + Check: assert.AssertThat(t, + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "auto_suspend", r.IntDefaultString)), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.#", "1")), + assert.Check(resource.TestCheckResourceAttr("snowflake_warehouse.w", "show_output.0.auto_suspend", "600")), + objectassert.Warehouse(t, id).HasAutoSuspend(600), ), }, // import when no type in config diff --git a/pkg/sdk/parameters.go b/pkg/sdk/parameters.go index 237af65994..53a2a2bed4 100644 --- a/pkg/sdk/parameters.go +++ b/pkg/sdk/parameters.go @@ -676,6 +676,27 @@ var AllSchemaParameters = []ObjectParameter{ ObjectParameterPipeExecutionPaused, } +type DatabaseParameter string + +const ( + DatabaseParameterDataRetentionTimeInDays DatabaseParameter = "DATA_RETENTION_TIME_IN_DAYS" + DatabaseParameterMaxDataExtensionTimeInDays DatabaseParameter = "MAX_DATA_EXTENSION_TIME_IN_DAYS" + DatabaseParameterExternalVolume DatabaseParameter = "EXTERNAL_VOLUME" + DatabaseParameterCatalog DatabaseParameter = "CATALOG" + DatabaseParameterReplaceInvalidCharacters DatabaseParameter = "REPLACE_INVALID_CHARACTERS" + DatabaseParameterDefaultDdlCollation DatabaseParameter = "DEFAULT_DDL_COLLATION" + DatabaseParameterStorageSerializationPolicy DatabaseParameter = "STORAGE_SERIALIZATION_POLICY" + DatabaseParameterLogLevel DatabaseParameter = "LOG_LEVEL" + DatabaseParameterTraceLevel DatabaseParameter = "TRACE_LEVEL" + DatabaseParameterSuspendTaskAfterNumFailures DatabaseParameter = "SUSPEND_TASK_AFTER_NUM_FAILURES" + DatabaseParameterTaskAutoRetryAttempts DatabaseParameter = "TASK_AUTO_RETRY_ATTEMPTS" + DatabaseParameterUserTaskManagedInitialWarehouseSize DatabaseParameter = "USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE" + DatabaseParameterUserTaskTimeoutMs DatabaseParameter = "USER_TASK_TIMEOUT_MS" + DatabaseParameterUserTaskMinimumTriggerIntervalInSeconds DatabaseParameter = "USER_TASK_MINIMUM_TRIGGER_INTERVAL_IN_SECONDS" + DatabaseParameterQuotedIdentifiersIgnoreCase DatabaseParameter = "QUOTED_IDENTIFIERS_IGNORE_CASE" + DatabaseParameterEnableConsoleOutput DatabaseParameter = "ENABLE_CONSOLE_OUTPUT" +) + // AccountParameters is based on https://docs.snowflake.com/en/sql-reference/parameters#account-parameters. type AccountParameters struct { // Account Parameters