-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Continue random ids rework (#2819)
Continuation of #2747 (topics connected with `NewAccountObjectIdentifier`): - `alterMaterializedViewQueryExternally` - moved to test helper - `checkDatabaseAndSchemaDataRetentionTime` - id part reworked, method left for assertions introduction - `checkDatabaseSchemaAndTableDataRetentionTime` - id part reworked, method left for assertions introduction - `unsafe_execute_acceptance_test.go` - id part reworked, some methods left for assertions introduction - `alterViewOwnershipExternally` - moved to test helper - check `app_role_1` - test role name extracted and parametrized in tests - check hardcoded `filter_by_role`, `stproc1`, `sp_pi`, `filterByRole`, `records` - added to procedure rework - ask @sfc-gh-jcieslak about `sdk.NewAccountObjectIdentifier("S3_STORAGE_INTEGRATION")`, `sdk.NewAccountObjectIdentifier("GCP_STORAGE_INTEGRATION")`, `sdk.NewAccountObjectIdentifier("AZURE_STORAGE_INTEGRATION")` - precreated integrations extracted - extract common helpers for `sdk.NewAccountObjectIdentifier("does_not_exist")` and similar - extracted - Fixed setup for multiple acceptance tests (to use random ids not random strings) Still left (connected with `NewAccountObjectIdentifier`): - `CreateDatabaseWithName` (and other similar helpers) - check `setup_test.go` Additional changes: - changed return type for `CurrentRole` and `CurrentUser` to ids - Fixed ShowByID for application roles - Added FAQ entry about possible identifier error - Introduced `DatabaseId()` and `SchemaId()` helpers to identifiers and convenience methods to use them - Introduced some additional placeholders (like role ids for ACCOUNTADMIN and ORGADMIN) - Moved check destroy to a common place
- Loading branch information
1 parent
751e5d3
commit f20940c
Showing
107 changed files
with
745 additions
and
636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type MaterializedViewClient struct { | ||
context *TestClientContext | ||
ids *IdsGenerator | ||
} | ||
|
||
func NewMaterializedViewClient(context *TestClientContext, idsGenerator *IdsGenerator) *MaterializedViewClient { | ||
return &MaterializedViewClient{ | ||
context: context, | ||
ids: idsGenerator, | ||
} | ||
} | ||
|
||
func (c *MaterializedViewClient) client() sdk.MaterializedViews { | ||
return c.context.client.MaterializedViews | ||
} | ||
|
||
func (c *MaterializedViewClient) CreateMaterializedView(t *testing.T, query string, orReplace bool) (*sdk.MaterializedView, func()) { | ||
t.Helper() | ||
return c.CreateMaterializedViewWithName(t, c.ids.RandomSchemaObjectIdentifier(), query, orReplace) | ||
} | ||
|
||
func (c *MaterializedViewClient) CreateMaterializedViewWithName(t *testing.T, id sdk.SchemaObjectIdentifier, query string, orReplace bool) (*sdk.MaterializedView, func()) { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
err := c.client().Create(ctx, sdk.NewCreateMaterializedViewRequest(id, query).WithOrReplace(sdk.Bool(orReplace))) | ||
require.NoError(t, err) | ||
|
||
view, err := c.client().ShowByID(ctx, id) | ||
require.NoError(t, err) | ||
|
||
return view, c.DropMaterializedViewFunc(t, id) | ||
} | ||
|
||
func (c *MaterializedViewClient) DropMaterializedViewFunc(t *testing.T, id sdk.SchemaObjectIdentifier) func() { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
return func() { | ||
err := c.client().Drop(ctx, sdk.NewDropMaterializedViewRequest(id).WithIfExists(sdk.Bool(true))) | ||
require.NoError(t, err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.