Skip to content

Commit

Permalink
Changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed Nov 26, 2024
1 parent d9e720d commit 62c7476
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/datasources/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package datasources

import (
"context"
"fmt"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/tracking"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources"
"fmt"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
Expand Down
2 changes: 0 additions & 2 deletions pkg/datasources/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/schemas"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/internal/tracking/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func (m Metadata) validate() error {
return errors.Join(errs...)
}

// NewTestMetadata is a helper constructor that is used only for testing purposes
func NewTestMetadata(version string, resource resources.Resource, operation Operation) Metadata {
// newTestMetadata is a helper constructor that is used only for testing purposes
func newTestMetadata(version string, resource resources.Resource, operation Operation) Metadata {
return Metadata{
SchemaVersion: CurrentSchemaVersion,
Version: version,
Expand Down
2 changes: 1 addition & 1 deletion pkg/internal/tracking/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func Test_Context(t *testing.T) {
metadata := NewTestMetadata("123", resources.Account, CreateOperation)
metadata := newTestMetadata("123", resources.Account, CreateOperation)
newMetadata := NewVersionedDatasourceMetadata(datasources.Databases)
ctx := context.Background()

Expand Down
6 changes: 3 additions & 3 deletions pkg/internal/tracking/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestTrimMetadata(t *testing.T) {
}

func TestAppendMetadata(t *testing.T) {
metadata := NewTestMetadata("123", resources.Account, CreateOperation)
metadata := newTestMetadata("123", resources.Account, CreateOperation)
sql := "SELECT 1"

bytes, err := json.Marshal(metadata)
Expand All @@ -61,7 +61,7 @@ func TestAppendMetadata(t *testing.T) {
}

func TestParseMetadata(t *testing.T) {
metadata := NewTestMetadata("123", resources.Account, CreateOperation)
metadata := newTestMetadata("123", resources.Account, CreateOperation)
bytes, err := json.Marshal(metadata)
require.NoError(t, err)
sql := fmt.Sprintf("SELECT 1 --%s %s", MetadataPrefix, string(bytes))
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestParseInvalidMetadataJson(t *testing.T) {
}

func TestParseMetadataFromInvalidSqlCommentPrefix(t *testing.T) {
metadata := NewTestMetadata("123", resources.Account, CreateOperation)
metadata := newTestMetadata("123", resources.Account, CreateOperation)
sql := "SELECT 1"

bytes, err := json.Marshal(metadata)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdk/testint/client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func TestInt_Client_AdditionalMetadata(t *testing.T) {
client := testClient(t)
metadata := tracking.NewTestMetadata("v1.13.1002-rc-test", resources.Database, tracking.CreateOperation)
metadata := tracking.Metadata{Version: "v1.13.1002-rc-test", Resource: resources.Database.String(), Operation: tracking.CreateOperation}

assertQueryMetadata := func(t *testing.T, queryId string) {
t.Helper()
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdk/testint/dynamic_table_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestInt_DynamicTableCreateAndDrop(t *testing.T) {
t.Run("create with usage tracking comment", func(t *testing.T) {
id := testClientHelper().Ids.RandomSchemaObjectIdentifier()
plainQuery := fmt.Sprintf("SELECT id FROM %s", tableTest.ID().FullyQualifiedName())
query, err := tracking.AppendMetadata(plainQuery, tracking.NewVersionedMetadata(resources.DynamicTable, tracking.CreateOperation))
query, err := tracking.AppendMetadata(plainQuery, tracking.NewVersionedResourceMetadata(resources.DynamicTable, tracking.CreateOperation))
require.NoError(t, err)

err = client.DynamicTables.Create(ctx, sdk.NewCreateDynamicTableRequest(id, testClientHelper().Ids.WarehouseId(), sdk.TargetLag{
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdk/testint/materialized_views_gen_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestInt_MaterializedViews(t *testing.T) {
t.Run("create materialized view: with usage tracking comment", func(t *testing.T) {
id := testClientHelper().Ids.RandomSchemaObjectIdentifier()
plainQuery := fmt.Sprintf("SELECT id FROM %s", table.ID().FullyQualifiedName())
query, err := tracking.AppendMetadata(plainQuery, tracking.NewVersionedMetadata(resources.MaterializedView, tracking.CreateOperation))
query, err := tracking.AppendMetadata(plainQuery, tracking.NewVersionedResourceMetadata(resources.MaterializedView, tracking.CreateOperation))
require.NoError(t, err)

view := createMaterializedViewWithRequest(t, sdk.NewCreateMaterializedViewRequest(id, query))
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdk/testint/views_gen_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func TestInt_Views(t *testing.T) {
t.Run("create view: with usage tracking comment", func(t *testing.T) {
id := testClientHelper().Ids.RandomSchemaObjectIdentifier()
plainQuery := "SELECT NULL AS TYPE"
query, err := tracking.AppendMetadata(plainQuery, tracking.NewVersionedMetadata(resources.View, tracking.CreateOperation))
query, err := tracking.AppendMetadata(plainQuery, tracking.NewVersionedResourceMetadata(resources.View, tracking.CreateOperation))
require.NoError(t, err)
request := sdk.NewCreateViewRequest(id, query)

Expand Down

0 comments on commit 62c7476

Please sign in to comment.