Skip to content

Commit

Permalink
fix: Adjust tests after Snowflake behavior change (#2404)
Browse files Browse the repository at this point in the history
Changes in tests:
- pipe test, that were intentionally documenting the incorrect behavior;
they started to fail after Snowflake 8.3.1 release; they have been
adjusted
- stream test was failing because of multiple objects named the same;
random name added
  • Loading branch information
sfc-gh-asawicki authored Jan 23, 2024
1 parent 3939dbe commit 8c03ffb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
15 changes: 8 additions & 7 deletions pkg/sdk/testint/pipes_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ func createPipeCopyStatement(t *testing.T, table *sdk.Table, stage *sdk.Stage) s
return fmt.Sprintf("COPY INTO %s\nFROM @%s", table.ID().FullyQualifiedName(), stage.ID().FullyQualifiedName())
}

func TestInt_IncorrectCreatePipeBehaviour(t *testing.T) {
// TestInt_CreatePipeWithStrangeSchemaName documented previous bad behavior. It changed with Snowflake 8.3.1 release.
// We leave the test for future reference.
func TestInt_CreatePipeWithStrangeSchemaName(t *testing.T) {
schemaIdentifier := sdk.NewDatabaseObjectIdentifier(testDb(t).Name, "tcK1>AJ+")

// creating a new schema on purpose
Expand All @@ -31,20 +33,18 @@ func TestInt_IncorrectCreatePipeBehaviour(t *testing.T) {
stage, stageCleanup := createStage(t, itc.client, sdk.NewSchemaObjectIdentifier(testDb(t).Name, testSchema(t).Name, stageName))
t.Cleanup(stageCleanup)

t.Run("if we have special characters in db or schema name, create pipe returns error in copy <> from <> section", func(t *testing.T) {
t.Run("if we have special characters in db or schema name, create pipe succeeds", func(t *testing.T) {
err := itc.client.Pipes.Create(
itc.ctx,
sdk.NewSchemaObjectIdentifier(testDb(t).Name, schema.Name, random.AlphanumericN(20)),
createPipeCopyStatement(t, table, stage),
&sdk.CreatePipeOptions{},
)

require.ErrorContains(t, err, "(42000): SQL compilation error:\nsyntax error line")
require.ErrorContains(t, err, "at position")
require.ErrorContains(t, err, "unexpected '>'")
require.NoError(t, err)
})

t.Run("the same works with using non fully qualified name for table", func(t *testing.T) {
t.Run("the same does not work when using non fully qualified name for table", func(t *testing.T) {
createCopyStatementWithoutQualifiersForStage := func(t *testing.T, table *sdk.Table, stage *sdk.Stage) string {
t.Helper()
require.NotNil(t, table, "table has to be created")
Expand All @@ -59,7 +59,8 @@ func TestInt_IncorrectCreatePipeBehaviour(t *testing.T) {
&sdk.CreatePipeOptions{},
)

require.NoError(t, err)
require.Error(t, err)
require.ErrorContains(t, err, "object does not exist or not authorized")
})
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/sdk/testint/streams_gen_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ func TestInt_Streams(t *testing.T) {
})

t.Run("CreateOnExternalTable", func(t *testing.T) {
stageID := sdk.NewSchemaObjectIdentifier(TestDatabaseName, TestSchemaName, "EXTERNAL_TABLE_STAGE")
stageName := random.AlphaN(10)
stageID := sdk.NewSchemaObjectIdentifier(TestDatabaseName, TestSchemaName, stageName)
stageLocation := fmt.Sprintf("@%s", stageID.FullyQualifiedName())
_, _ = createStageWithURL(t, client, stageID, nycWeatherDataURL)

Expand Down

0 comments on commit 8c03ffb

Please sign in to comment.