Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Test support for object renaming #3130

Merged
merged 7 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ test-architecture: ## check architecture constraints between packages
test-client: ## runs test that checks sdk.Client without instrumentedsql
SF_TF_NO_INSTRUMENTED_SQL=1 SF_TF_GOSNOWFLAKE_LOG_LEVEL=debug go test ./pkg/sdk/internal/client/... -v

test-object-renaming: ## runs tests in object_renaming_acceptance_test.go
TEST_SF_TF_ENABLE_OBJECT_RENAMING=1 go test ./pkg/resources/object_renaming_acceptace_test.go -v

test-acceptance-%: ## run acceptance tests for the given resource only, e.g. test-acceptance-Warehouse
TF_ACC=1 TF_LOG=DEBUG SF_TF_ACC_TEST_CONFIGURE_CLIENT_ONCE=true go test -run ^TestAcc_$*_ -v -timeout=20m ./pkg/resources

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ var allResourceSchemaDefs = []ResourceSchemaDef{
name: "View",
schema: resources.View().Schema,
},
{
name: "Database",
schema: resources.Database().Schema,
},
{
name: "DatabaseRole",
schema: resources.DatabaseRole().Schema,
Expand All @@ -53,6 +57,10 @@ var allResourceSchemaDefs = []ResourceSchemaDef{
name: "RowAccessPolicy",
schema: resources.RowAccessPolicy().Schema,
},
{
name: "Schema",
schema: resources.Schema().Schema,
},
{
name: "MaskingPolicy",
schema: resources.MaskingPolicy().Schema,
Expand Down
13 changes: 11 additions & 2 deletions pkg/acceptance/bettertestspoc/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type ResourceModel interface {
SetResourceName(name string)
ResourceReference() string
DependsOn() []string
SetDependsOn(values []string)
SetDependsOn(values ...string)
}

type ResourceModelMeta struct {
Expand Down Expand Up @@ -54,7 +54,7 @@ func (m *ResourceModelMeta) DependsOn() []string {
return m.dependsOn
}

func (m *ResourceModelMeta) SetDependsOn(values []string) {
func (m *ResourceModelMeta) SetDependsOn(values ...string) {
m.dependsOn = values
}

Expand Down Expand Up @@ -99,6 +99,15 @@ func FromModel(t *testing.T, model ResourceModel) string {
return s
}

func FromModels(t *testing.T, models ...ResourceModel) string {
t.Helper()
var sb strings.Builder
for _, model := range models {
sb.WriteString(FromModel(t, model) + "\n")
}
return sb.String()
}

// ConfigVariablesFromModel constructs config.Variables needed in acceptance tests that are using ConfigVariables in
// combination with ConfigDirectory. It's necessary for cases not supported by FromModel, like lists of objects.
func ConfigVariablesFromModel(t *testing.T, model ResourceModel) tfconfig.Variables {
Expand Down
283 changes: 283 additions & 0 deletions pkg/acceptance/bettertestspoc/config/model/database_model_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package model
sfc-gh-jmichalak marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading