diff --git a/pkg/acceptance/asserts.go b/pkg/acceptance/asserts.go index 46f9548ff3f..4ce547dfa9a 100644 --- a/pkg/acceptance/asserts.go +++ b/pkg/acceptance/asserts.go @@ -2,8 +2,9 @@ package acceptance import ( "fmt" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" "strconv" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) func IsGreaterOrEqualTo(greaterOrEqualValue int) resource.CheckResourceAttrWithFunc { diff --git a/pkg/acceptance/bettertestspoc/assert/commons.go b/pkg/acceptance/bettertestspoc/assert/commons.go index 3491f8e5cde..136fbf93d23 100644 --- a/pkg/acceptance/bettertestspoc/assert/commons.go +++ b/pkg/acceptance/bettertestspoc/assert/commons.go @@ -3,11 +3,12 @@ package assert import ( "errors" "fmt" - "golang.org/x/exp/maps" "strconv" "strings" "testing" + "golang.org/x/exp/maps" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" ) @@ -105,7 +106,6 @@ func AssertThatObject(t *testing.T, objectAssert InPlaceAssertionVerifier) { objectAssert.VerifyAll(t) } -// TODO: This function should iterate over items and look for list item in attributes that matches ALL items' entries AT ONCE (currently it's a pretty dumb assert running through all attributes) func HasListItemsOrderIndependent(resourceKey string, attributePath string, expectedItems []map[string]string) resource.TestCheckFunc { return func(state *terraform.State) error { var actualItems []map[string]string @@ -120,7 +120,7 @@ func HasListItemsOrderIndependent(resourceKey string, attributePath string, expe if attr == "#" { attrValueLen, err := strconv.Atoi(attrValue) if err != nil { - return fmt.Errorf("failed to convert length of the attribute %s: %s", attrKey, err) + return fmt.Errorf("failed to convert length of the attribute %s: %w", attrKey, err) } if len(expectedItems) != attrValueLen { return fmt.Errorf("expected to find %d items in %s, but found %d", len(expectedItems), attributePath, attrValueLen) diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go index cba3663a574..4f618ddfa53 100644 --- a/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go @@ -41,10 +41,6 @@ var allResourceSchemaDefs = []ResourceSchemaDef{ name: "View", schema: resources.View().Schema, }, - { - name: "Database", - schema: resources.Database().Schema, - }, { name: "DatabaseRole", schema: resources.DatabaseRole().Schema, @@ -57,10 +53,6 @@ var allResourceSchemaDefs = []ResourceSchemaDef{ name: "RowAccessPolicy", schema: resources.RowAccessPolicy().Schema, }, - { - name: "Schema", - schema: resources.Schema().Schema, - }, { name: "MaskingPolicy", schema: resources.MaskingPolicy().Schema, diff --git a/pkg/acceptance/bettertestspoc/config/model/database_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/database_model_gen.go deleted file mode 100644 index 813b6b96e37..00000000000 --- a/pkg/acceptance/bettertestspoc/config/model/database_model_gen.go +++ /dev/null @@ -1,283 +0,0 @@ -// Code generated by config model builder generator; DO NOT EDIT. - -package model - -import ( - tfconfig "github.com/hashicorp/terraform-plugin-testing/config" - - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" -) - -type DatabaseModel struct { - Catalog tfconfig.Variable `json:"catalog,omitempty"` - Comment tfconfig.Variable `json:"comment,omitempty"` - DataRetentionTimeInDays tfconfig.Variable `json:"data_retention_time_in_days,omitempty"` - DefaultDdlCollation tfconfig.Variable `json:"default_ddl_collation,omitempty"` - DropPublicSchemaOnCreation tfconfig.Variable `json:"drop_public_schema_on_creation,omitempty"` - EnableConsoleOutput tfconfig.Variable `json:"enable_console_output,omitempty"` - ExternalVolume tfconfig.Variable `json:"external_volume,omitempty"` - FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` - IsTransient tfconfig.Variable `json:"is_transient,omitempty"` - LogLevel tfconfig.Variable `json:"log_level,omitempty"` - MaxDataExtensionTimeInDays tfconfig.Variable `json:"max_data_extension_time_in_days,omitempty"` - Name tfconfig.Variable `json:"name,omitempty"` - QuotedIdentifiersIgnoreCase tfconfig.Variable `json:"quoted_identifiers_ignore_case,omitempty"` - ReplaceInvalidCharacters tfconfig.Variable `json:"replace_invalid_characters,omitempty"` - Replication tfconfig.Variable `json:"replication,omitempty"` - StorageSerializationPolicy tfconfig.Variable `json:"storage_serialization_policy,omitempty"` - SuspendTaskAfterNumFailures tfconfig.Variable `json:"suspend_task_after_num_failures,omitempty"` - TaskAutoRetryAttempts tfconfig.Variable `json:"task_auto_retry_attempts,omitempty"` - TraceLevel tfconfig.Variable `json:"trace_level,omitempty"` - UserTaskManagedInitialWarehouseSize tfconfig.Variable `json:"user_task_managed_initial_warehouse_size,omitempty"` - UserTaskMinimumTriggerIntervalInSeconds tfconfig.Variable `json:"user_task_minimum_trigger_interval_in_seconds,omitempty"` - UserTaskTimeoutMs tfconfig.Variable `json:"user_task_timeout_ms,omitempty"` - - *config.ResourceModelMeta -} - -///////////////////////////////////////////////// -// Basic builders (resource name and required) // -///////////////////////////////////////////////// - -func Database( - resourceName string, - name string, -) *DatabaseModel { - d := &DatabaseModel{ResourceModelMeta: config.Meta(resourceName, resources.Database)} - d.WithName(name) - return d -} - -func DatabaseWithDefaultMeta( - name string, -) *DatabaseModel { - d := &DatabaseModel{ResourceModelMeta: config.DefaultMeta(resources.Database)} - d.WithName(name) - return d -} - -///////////////////////////////// -// below all the proper values // -///////////////////////////////// - -func (d *DatabaseModel) WithCatalog(catalog string) *DatabaseModel { - d.Catalog = tfconfig.StringVariable(catalog) - return d -} - -func (d *DatabaseModel) WithComment(comment string) *DatabaseModel { - d.Comment = tfconfig.StringVariable(comment) - return d -} - -func (d *DatabaseModel) WithDataRetentionTimeInDays(dataRetentionTimeInDays int) *DatabaseModel { - d.DataRetentionTimeInDays = tfconfig.IntegerVariable(dataRetentionTimeInDays) - return d -} - -func (d *DatabaseModel) WithDefaultDdlCollation(defaultDdlCollation string) *DatabaseModel { - d.DefaultDdlCollation = tfconfig.StringVariable(defaultDdlCollation) - return d -} - -func (d *DatabaseModel) WithDropPublicSchemaOnCreation(dropPublicSchemaOnCreation bool) *DatabaseModel { - d.DropPublicSchemaOnCreation = tfconfig.BoolVariable(dropPublicSchemaOnCreation) - return d -} - -func (d *DatabaseModel) WithEnableConsoleOutput(enableConsoleOutput bool) *DatabaseModel { - d.EnableConsoleOutput = tfconfig.BoolVariable(enableConsoleOutput) - return d -} - -func (d *DatabaseModel) WithExternalVolume(externalVolume string) *DatabaseModel { - d.ExternalVolume = tfconfig.StringVariable(externalVolume) - return d -} - -func (d *DatabaseModel) WithFullyQualifiedName(fullyQualifiedName string) *DatabaseModel { - d.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) - return d -} - -func (d *DatabaseModel) WithIsTransient(isTransient bool) *DatabaseModel { - d.IsTransient = tfconfig.BoolVariable(isTransient) - return d -} - -func (d *DatabaseModel) WithLogLevel(logLevel string) *DatabaseModel { - d.LogLevel = tfconfig.StringVariable(logLevel) - return d -} - -func (d *DatabaseModel) WithMaxDataExtensionTimeInDays(maxDataExtensionTimeInDays int) *DatabaseModel { - d.MaxDataExtensionTimeInDays = tfconfig.IntegerVariable(maxDataExtensionTimeInDays) - return d -} - -func (d *DatabaseModel) WithName(name string) *DatabaseModel { - d.Name = tfconfig.StringVariable(name) - return d -} - -func (d *DatabaseModel) WithQuotedIdentifiersIgnoreCase(quotedIdentifiersIgnoreCase bool) *DatabaseModel { - d.QuotedIdentifiersIgnoreCase = tfconfig.BoolVariable(quotedIdentifiersIgnoreCase) - return d -} - -func (d *DatabaseModel) WithReplaceInvalidCharacters(replaceInvalidCharacters bool) *DatabaseModel { - d.ReplaceInvalidCharacters = tfconfig.BoolVariable(replaceInvalidCharacters) - return d -} - -// replication attribute type is not yet supported, so WithReplication can't be generated - -func (d *DatabaseModel) WithStorageSerializationPolicy(storageSerializationPolicy string) *DatabaseModel { - d.StorageSerializationPolicy = tfconfig.StringVariable(storageSerializationPolicy) - return d -} - -func (d *DatabaseModel) WithSuspendTaskAfterNumFailures(suspendTaskAfterNumFailures int) *DatabaseModel { - d.SuspendTaskAfterNumFailures = tfconfig.IntegerVariable(suspendTaskAfterNumFailures) - return d -} - -func (d *DatabaseModel) WithTaskAutoRetryAttempts(taskAutoRetryAttempts int) *DatabaseModel { - d.TaskAutoRetryAttempts = tfconfig.IntegerVariable(taskAutoRetryAttempts) - return d -} - -func (d *DatabaseModel) WithTraceLevel(traceLevel string) *DatabaseModel { - d.TraceLevel = tfconfig.StringVariable(traceLevel) - return d -} - -func (d *DatabaseModel) WithUserTaskManagedInitialWarehouseSize(userTaskManagedInitialWarehouseSize string) *DatabaseModel { - d.UserTaskManagedInitialWarehouseSize = tfconfig.StringVariable(userTaskManagedInitialWarehouseSize) - return d -} - -func (d *DatabaseModel) WithUserTaskMinimumTriggerIntervalInSeconds(userTaskMinimumTriggerIntervalInSeconds int) *DatabaseModel { - d.UserTaskMinimumTriggerIntervalInSeconds = tfconfig.IntegerVariable(userTaskMinimumTriggerIntervalInSeconds) - return d -} - -func (d *DatabaseModel) WithUserTaskTimeoutMs(userTaskTimeoutMs int) *DatabaseModel { - d.UserTaskTimeoutMs = tfconfig.IntegerVariable(userTaskTimeoutMs) - return d -} - -////////////////////////////////////////// -// below it's possible to set any value // -////////////////////////////////////////// - -func (d *DatabaseModel) WithCatalogValue(value tfconfig.Variable) *DatabaseModel { - d.Catalog = value - return d -} - -func (d *DatabaseModel) WithCommentValue(value tfconfig.Variable) *DatabaseModel { - d.Comment = value - return d -} - -func (d *DatabaseModel) WithDataRetentionTimeInDaysValue(value tfconfig.Variable) *DatabaseModel { - d.DataRetentionTimeInDays = value - return d -} - -func (d *DatabaseModel) WithDefaultDdlCollationValue(value tfconfig.Variable) *DatabaseModel { - d.DefaultDdlCollation = value - return d -} - -func (d *DatabaseModel) WithDropPublicSchemaOnCreationValue(value tfconfig.Variable) *DatabaseModel { - d.DropPublicSchemaOnCreation = value - return d -} - -func (d *DatabaseModel) WithEnableConsoleOutputValue(value tfconfig.Variable) *DatabaseModel { - d.EnableConsoleOutput = value - return d -} - -func (d *DatabaseModel) WithExternalVolumeValue(value tfconfig.Variable) *DatabaseModel { - d.ExternalVolume = value - return d -} - -func (d *DatabaseModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *DatabaseModel { - d.FullyQualifiedName = value - return d -} - -func (d *DatabaseModel) WithIsTransientValue(value tfconfig.Variable) *DatabaseModel { - d.IsTransient = value - return d -} - -func (d *DatabaseModel) WithLogLevelValue(value tfconfig.Variable) *DatabaseModel { - d.LogLevel = value - return d -} - -func (d *DatabaseModel) WithMaxDataExtensionTimeInDaysValue(value tfconfig.Variable) *DatabaseModel { - d.MaxDataExtensionTimeInDays = value - return d -} - -func (d *DatabaseModel) WithNameValue(value tfconfig.Variable) *DatabaseModel { - d.Name = value - return d -} - -func (d *DatabaseModel) WithQuotedIdentifiersIgnoreCaseValue(value tfconfig.Variable) *DatabaseModel { - d.QuotedIdentifiersIgnoreCase = value - return d -} - -func (d *DatabaseModel) WithReplaceInvalidCharactersValue(value tfconfig.Variable) *DatabaseModel { - d.ReplaceInvalidCharacters = value - return d -} - -func (d *DatabaseModel) WithReplicationValue(value tfconfig.Variable) *DatabaseModel { - d.Replication = value - return d -} - -func (d *DatabaseModel) WithStorageSerializationPolicyValue(value tfconfig.Variable) *DatabaseModel { - d.StorageSerializationPolicy = value - return d -} - -func (d *DatabaseModel) WithSuspendTaskAfterNumFailuresValue(value tfconfig.Variable) *DatabaseModel { - d.SuspendTaskAfterNumFailures = value - return d -} - -func (d *DatabaseModel) WithTaskAutoRetryAttemptsValue(value tfconfig.Variable) *DatabaseModel { - d.TaskAutoRetryAttempts = value - return d -} - -func (d *DatabaseModel) WithTraceLevelValue(value tfconfig.Variable) *DatabaseModel { - d.TraceLevel = value - return d -} - -func (d *DatabaseModel) WithUserTaskManagedInitialWarehouseSizeValue(value tfconfig.Variable) *DatabaseModel { - d.UserTaskManagedInitialWarehouseSize = value - return d -} - -func (d *DatabaseModel) WithUserTaskMinimumTriggerIntervalInSecondsValue(value tfconfig.Variable) *DatabaseModel { - d.UserTaskMinimumTriggerIntervalInSeconds = value - return d -} - -func (d *DatabaseModel) WithUserTaskTimeoutMsValue(value tfconfig.Variable) *DatabaseModel { - d.UserTaskTimeoutMs = value - return d -} diff --git a/pkg/acceptance/bettertestspoc/config/model/schema_model_ext.go b/pkg/acceptance/bettertestspoc/config/model/schema_model_ext.go deleted file mode 100644 index 8b537907051..00000000000 --- a/pkg/acceptance/bettertestspoc/config/model/schema_model_ext.go +++ /dev/null @@ -1 +0,0 @@ -package model diff --git a/pkg/acceptance/bettertestspoc/config/model/schema_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/schema_model_gen.go deleted file mode 100644 index e83ac5058d1..00000000000 --- a/pkg/acceptance/bettertestspoc/config/model/schema_model_gen.go +++ /dev/null @@ -1,301 +0,0 @@ -// Code generated by config model builder generator; DO NOT EDIT. - -package model - -import ( - tfconfig "github.com/hashicorp/terraform-plugin-testing/config" - - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" -) - -type SchemaModel struct { - Catalog tfconfig.Variable `json:"catalog,omitempty"` - Comment tfconfig.Variable `json:"comment,omitempty"` - DataRetentionTimeInDays tfconfig.Variable `json:"data_retention_time_in_days,omitempty"` - Database tfconfig.Variable `json:"database,omitempty"` - DefaultDdlCollation tfconfig.Variable `json:"default_ddl_collation,omitempty"` - EnableConsoleOutput tfconfig.Variable `json:"enable_console_output,omitempty"` - ExternalVolume tfconfig.Variable `json:"external_volume,omitempty"` - FullyQualifiedName tfconfig.Variable `json:"fully_qualified_name,omitempty"` - IsTransient tfconfig.Variable `json:"is_transient,omitempty"` - LogLevel tfconfig.Variable `json:"log_level,omitempty"` - MaxDataExtensionTimeInDays tfconfig.Variable `json:"max_data_extension_time_in_days,omitempty"` - Name tfconfig.Variable `json:"name,omitempty"` - PipeExecutionPaused tfconfig.Variable `json:"pipe_execution_paused,omitempty"` - QuotedIdentifiersIgnoreCase tfconfig.Variable `json:"quoted_identifiers_ignore_case,omitempty"` - ReplaceInvalidCharacters tfconfig.Variable `json:"replace_invalid_characters,omitempty"` - StorageSerializationPolicy tfconfig.Variable `json:"storage_serialization_policy,omitempty"` - SuspendTaskAfterNumFailures tfconfig.Variable `json:"suspend_task_after_num_failures,omitempty"` - TaskAutoRetryAttempts tfconfig.Variable `json:"task_auto_retry_attempts,omitempty"` - TraceLevel tfconfig.Variable `json:"trace_level,omitempty"` - UserTaskManagedInitialWarehouseSize tfconfig.Variable `json:"user_task_managed_initial_warehouse_size,omitempty"` - UserTaskMinimumTriggerIntervalInSeconds tfconfig.Variable `json:"user_task_minimum_trigger_interval_in_seconds,omitempty"` - UserTaskTimeoutMs tfconfig.Variable `json:"user_task_timeout_ms,omitempty"` - WithManagedAccess tfconfig.Variable `json:"with_managed_access,omitempty"` - - *config.ResourceModelMeta -} - -///////////////////////////////////////////////// -// Basic builders (resource name and required) // -///////////////////////////////////////////////// - -func Schema( - resourceName string, - database string, - name string, -) *SchemaModel { - s := &SchemaModel{ResourceModelMeta: config.Meta(resourceName, resources.Schema)} - s.WithDatabase(database) - s.WithName(name) - return s -} - -func SchemaWithDefaultMeta( - database string, - name string, -) *SchemaModel { - s := &SchemaModel{ResourceModelMeta: config.DefaultMeta(resources.Schema)} - s.WithDatabase(database) - s.WithName(name) - return s -} - -///////////////////////////////// -// below all the proper values // -///////////////////////////////// - -func (s *SchemaModel) WithCatalog(catalog string) *SchemaModel { - s.Catalog = tfconfig.StringVariable(catalog) - return s -} - -func (s *SchemaModel) WithComment(comment string) *SchemaModel { - s.Comment = tfconfig.StringVariable(comment) - return s -} - -func (s *SchemaModel) WithDataRetentionTimeInDays(dataRetentionTimeInDays int) *SchemaModel { - s.DataRetentionTimeInDays = tfconfig.IntegerVariable(dataRetentionTimeInDays) - return s -} - -func (s *SchemaModel) WithDatabase(database string) *SchemaModel { - s.Database = tfconfig.StringVariable(database) - return s -} - -func (s *SchemaModel) WithDefaultDdlCollation(defaultDdlCollation string) *SchemaModel { - s.DefaultDdlCollation = tfconfig.StringVariable(defaultDdlCollation) - return s -} - -func (s *SchemaModel) WithEnableConsoleOutput(enableConsoleOutput bool) *SchemaModel { - s.EnableConsoleOutput = tfconfig.BoolVariable(enableConsoleOutput) - return s -} - -func (s *SchemaModel) WithExternalVolume(externalVolume string) *SchemaModel { - s.ExternalVolume = tfconfig.StringVariable(externalVolume) - return s -} - -func (s *SchemaModel) WithFullyQualifiedName(fullyQualifiedName string) *SchemaModel { - s.FullyQualifiedName = tfconfig.StringVariable(fullyQualifiedName) - return s -} - -func (s *SchemaModel) WithIsTransient(isTransient string) *SchemaModel { - s.IsTransient = tfconfig.StringVariable(isTransient) - return s -} - -func (s *SchemaModel) WithLogLevel(logLevel string) *SchemaModel { - s.LogLevel = tfconfig.StringVariable(logLevel) - return s -} - -func (s *SchemaModel) WithMaxDataExtensionTimeInDays(maxDataExtensionTimeInDays int) *SchemaModel { - s.MaxDataExtensionTimeInDays = tfconfig.IntegerVariable(maxDataExtensionTimeInDays) - return s -} - -func (s *SchemaModel) WithName(name string) *SchemaModel { - s.Name = tfconfig.StringVariable(name) - return s -} - -func (s *SchemaModel) WithPipeExecutionPaused(pipeExecutionPaused bool) *SchemaModel { - s.PipeExecutionPaused = tfconfig.BoolVariable(pipeExecutionPaused) - return s -} - -func (s *SchemaModel) WithQuotedIdentifiersIgnoreCase(quotedIdentifiersIgnoreCase bool) *SchemaModel { - s.QuotedIdentifiersIgnoreCase = tfconfig.BoolVariable(quotedIdentifiersIgnoreCase) - return s -} - -func (s *SchemaModel) WithReplaceInvalidCharacters(replaceInvalidCharacters bool) *SchemaModel { - s.ReplaceInvalidCharacters = tfconfig.BoolVariable(replaceInvalidCharacters) - return s -} - -func (s *SchemaModel) WithStorageSerializationPolicy(storageSerializationPolicy string) *SchemaModel { - s.StorageSerializationPolicy = tfconfig.StringVariable(storageSerializationPolicy) - return s -} - -func (s *SchemaModel) WithSuspendTaskAfterNumFailures(suspendTaskAfterNumFailures int) *SchemaModel { - s.SuspendTaskAfterNumFailures = tfconfig.IntegerVariable(suspendTaskAfterNumFailures) - return s -} - -func (s *SchemaModel) WithTaskAutoRetryAttempts(taskAutoRetryAttempts int) *SchemaModel { - s.TaskAutoRetryAttempts = tfconfig.IntegerVariable(taskAutoRetryAttempts) - return s -} - -func (s *SchemaModel) WithTraceLevel(traceLevel string) *SchemaModel { - s.TraceLevel = tfconfig.StringVariable(traceLevel) - return s -} - -func (s *SchemaModel) WithUserTaskManagedInitialWarehouseSize(userTaskManagedInitialWarehouseSize string) *SchemaModel { - s.UserTaskManagedInitialWarehouseSize = tfconfig.StringVariable(userTaskManagedInitialWarehouseSize) - return s -} - -func (s *SchemaModel) WithUserTaskMinimumTriggerIntervalInSeconds(userTaskMinimumTriggerIntervalInSeconds int) *SchemaModel { - s.UserTaskMinimumTriggerIntervalInSeconds = tfconfig.IntegerVariable(userTaskMinimumTriggerIntervalInSeconds) - return s -} - -func (s *SchemaModel) WithUserTaskTimeoutMs(userTaskTimeoutMs int) *SchemaModel { - s.UserTaskTimeoutMs = tfconfig.IntegerVariable(userTaskTimeoutMs) - return s -} - -func (s *SchemaModel) WithWithManagedAccess(withManagedAccess string) *SchemaModel { - s.WithManagedAccess = tfconfig.StringVariable(withManagedAccess) - return s -} - -////////////////////////////////////////// -// below it's possible to set any value // -////////////////////////////////////////// - -func (s *SchemaModel) WithCatalogValue(value tfconfig.Variable) *SchemaModel { - s.Catalog = value - return s -} - -func (s *SchemaModel) WithCommentValue(value tfconfig.Variable) *SchemaModel { - s.Comment = value - return s -} - -func (s *SchemaModel) WithDataRetentionTimeInDaysValue(value tfconfig.Variable) *SchemaModel { - s.DataRetentionTimeInDays = value - return s -} - -func (s *SchemaModel) WithDatabaseValue(value tfconfig.Variable) *SchemaModel { - s.Database = value - return s -} - -func (s *SchemaModel) WithDefaultDdlCollationValue(value tfconfig.Variable) *SchemaModel { - s.DefaultDdlCollation = value - return s -} - -func (s *SchemaModel) WithEnableConsoleOutputValue(value tfconfig.Variable) *SchemaModel { - s.EnableConsoleOutput = value - return s -} - -func (s *SchemaModel) WithExternalVolumeValue(value tfconfig.Variable) *SchemaModel { - s.ExternalVolume = value - return s -} - -func (s *SchemaModel) WithFullyQualifiedNameValue(value tfconfig.Variable) *SchemaModel { - s.FullyQualifiedName = value - return s -} - -func (s *SchemaModel) WithIsTransientValue(value tfconfig.Variable) *SchemaModel { - s.IsTransient = value - return s -} - -func (s *SchemaModel) WithLogLevelValue(value tfconfig.Variable) *SchemaModel { - s.LogLevel = value - return s -} - -func (s *SchemaModel) WithMaxDataExtensionTimeInDaysValue(value tfconfig.Variable) *SchemaModel { - s.MaxDataExtensionTimeInDays = value - return s -} - -func (s *SchemaModel) WithNameValue(value tfconfig.Variable) *SchemaModel { - s.Name = value - return s -} - -func (s *SchemaModel) WithPipeExecutionPausedValue(value tfconfig.Variable) *SchemaModel { - s.PipeExecutionPaused = value - return s -} - -func (s *SchemaModel) WithQuotedIdentifiersIgnoreCaseValue(value tfconfig.Variable) *SchemaModel { - s.QuotedIdentifiersIgnoreCase = value - return s -} - -func (s *SchemaModel) WithReplaceInvalidCharactersValue(value tfconfig.Variable) *SchemaModel { - s.ReplaceInvalidCharacters = value - return s -} - -func (s *SchemaModel) WithStorageSerializationPolicyValue(value tfconfig.Variable) *SchemaModel { - s.StorageSerializationPolicy = value - return s -} - -func (s *SchemaModel) WithSuspendTaskAfterNumFailuresValue(value tfconfig.Variable) *SchemaModel { - s.SuspendTaskAfterNumFailures = value - return s -} - -func (s *SchemaModel) WithTaskAutoRetryAttemptsValue(value tfconfig.Variable) *SchemaModel { - s.TaskAutoRetryAttempts = value - return s -} - -func (s *SchemaModel) WithTraceLevelValue(value tfconfig.Variable) *SchemaModel { - s.TraceLevel = value - return s -} - -func (s *SchemaModel) WithUserTaskManagedInitialWarehouseSizeValue(value tfconfig.Variable) *SchemaModel { - s.UserTaskManagedInitialWarehouseSize = value - return s -} - -func (s *SchemaModel) WithUserTaskMinimumTriggerIntervalInSecondsValue(value tfconfig.Variable) *SchemaModel { - s.UserTaskMinimumTriggerIntervalInSeconds = value - return s -} - -func (s *SchemaModel) WithUserTaskTimeoutMsValue(value tfconfig.Variable) *SchemaModel { - s.UserTaskTimeoutMs = value - return s -} - -func (s *SchemaModel) WithWithManagedAccessValue(value tfconfig.Variable) *SchemaModel { - s.WithManagedAccess = value - return s -} diff --git a/pkg/acceptance/helpers/database_client.go b/pkg/acceptance/helpers/database_client.go index 640dbb896f8..a0ea93ebabd 100644 --- a/pkg/acceptance/helpers/database_client.go +++ b/pkg/acceptance/helpers/database_client.go @@ -48,14 +48,6 @@ func (c *DatabaseClient) CreateDatabaseWithOptions(t *testing.T, id sdk.AccountO return database, c.DropDatabaseFunc(t, id) } -func (c *DatabaseClient) Alter(t *testing.T, id sdk.AccountObjectIdentifier, opts *sdk.AlterDatabaseOptions) { - t.Helper() - ctx := context.Background() - - err := c.client().Alter(ctx, id, opts) - require.NoError(t, err) -} - func (c *DatabaseClient) DropDatabaseFunc(t *testing.T, id sdk.AccountObjectIdentifier) func() { t.Helper() return func() { require.NoError(t, c.DropDatabase(t, id)) } @@ -192,3 +184,11 @@ func (c *DatabaseClient) ShowAllReplicationDatabases(t *testing.T) ([]sdk.Replic return c.context.client.ReplicationFunctions.ShowReplicationDatabases(ctx, nil) } + +func (c *DatabaseClient) Alter(t *testing.T, id sdk.AccountObjectIdentifier, opts *sdk.AlterDatabaseOptions) { + t.Helper() + ctx := context.Background() + + err := c.client().Alter(ctx, id, opts) + require.NoError(t, err) +} diff --git a/pkg/acceptance/helpers/schema_client.go b/pkg/acceptance/helpers/schema_client.go index d1baae5c97d..7c58b90560b 100644 --- a/pkg/acceptance/helpers/schema_client.go +++ b/pkg/acceptance/helpers/schema_client.go @@ -55,14 +55,6 @@ func (c *SchemaClient) CreateSchemaWithOpts(t *testing.T, id sdk.DatabaseObjectI return schema, c.DropSchemaFunc(t, id) } -func (c *SchemaClient) Alter(t *testing.T, id sdk.DatabaseObjectIdentifier, opts *sdk.AlterSchemaOptions) { - t.Helper() - ctx := context.Background() - - err := c.client().Alter(ctx, id, opts) - require.NoError(t, err) -} - func (c *SchemaClient) DropSchemaFunc(t *testing.T, id sdk.DatabaseObjectIdentifier) func() { t.Helper() ctx := context.Background() @@ -112,3 +104,11 @@ func (c *SchemaClient) ShowWithOptions(t *testing.T, opts *sdk.ShowSchemaOptions require.NoError(t, err) return schemas } + +func (c *SchemaClient) Alter(t *testing.T, id sdk.DatabaseObjectIdentifier, opts *sdk.AlterSchemaOptions) { + t.Helper() + ctx := context.Background() + + err := c.client().Alter(ctx, id, opts) + require.NoError(t, err) +} diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go index fb8f462e547..781bcf6572b 100644 --- a/pkg/provider/provider.go +++ b/pkg/provider/provider.go @@ -3,13 +3,14 @@ package provider import ( "errors" "fmt" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs" "net" "net/url" "os" "strings" "time" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/datasources" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider/docs" diff --git a/pkg/resources/object_renaming_lists_and_sets.go b/pkg/resources/object_renaming_lists_and_sets.go index 0de739986e9..7a25c5815df 100644 --- a/pkg/resources/object_renaming_lists_and_sets.go +++ b/pkg/resources/object_renaming_lists_and_sets.go @@ -4,14 +4,15 @@ import ( "context" "errors" "fmt" + "log" + "strconv" + "strings" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "golang.org/x/exp/slices" - "log" - "strconv" - "strings" ) type objectRenamingDatabaseListItem struct { @@ -222,9 +223,7 @@ func UpdateObjectRenamingListsAndSets(ctx context.Context, d *schema.ResourceDat }) } - for _, addedItem := range addedItems { - ObjectRenamingDatabaseInstance.List = append(ObjectRenamingDatabaseInstance.List, addedItem) - } + ObjectRenamingDatabaseInstance.List = append(ObjectRenamingDatabaseInstance.List, addedItems...) } if d.HasChange("ordered_list") { diff --git a/pkg/resources/object_renaming_lists_and_sets_acceptance_test.go b/pkg/resources/object_renaming_lists_and_sets_acceptance_test.go index 18c57defc44..b94f9ed2003 100644 --- a/pkg/resources/object_renaming_lists_and_sets_acceptance_test.go +++ b/pkg/resources/object_renaming_lists_and_sets_acceptance_test.go @@ -2,6 +2,8 @@ package resources_test import ( "fmt" + "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/acceptance/testenvs" @@ -9,7 +11,6 @@ import ( "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/tfversion" - "testing" ) func TestAcc_BasicListFlow(t *testing.T) {