Skip to content

Commit

Permalink
int tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed Oct 12, 2023
1 parent 261ab6f commit 5969b8e
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 98 deletions.
11 changes: 0 additions & 11 deletions pkg/sdk/testint/external_tables_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,3 @@ func TestInt_ExternalTables(t *testing.T) {
})
})
}

type AllowedValue struct {
Value string `ddl:"keyword,single_quotes"`
}

func TestT(t *testing.T) {
a := AllowedValue{Value: "123"}
b, err := structToSQL(a)
require.NoError(t, err)
assert.Equal(t, `'123'`, b)
}
33 changes: 23 additions & 10 deletions pkg/sdk/testint/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,19 +279,20 @@ func createTagWithOptions(t *testing.T, client *sdk.Client, database *sdk.Databa
}
}

func createStageWithName(t *testing.T, client *sdk.Client, name string) (*string, func()) {
func createStageWithDirectory(t *testing.T, client *sdk.Client, database *sdk.Database, schema *sdk.Schema, name string) (*sdk.Stage, func()) {
t.Helper()
ctx := context.Background()
stageCleanup := func() {
_, err := client.ExecForTests(ctx, fmt.Sprintf("DROP STAGE %s", name))
require.NoError(t, err)
}
_, err := client.ExecForTests(ctx, fmt.Sprintf("CREATE STAGE %s", name))
if err != nil {
return nil, stageCleanup
}
_, err := client.ExecForTests(ctx, fmt.Sprintf(`CREATE STAGE "%s" DIRECTORY = (ENABLE = TRUE)`, name))
require.NoError(t, err)
return &name, stageCleanup

return &sdk.Stage{
DatabaseName: database.Name,
SchemaName: schema.Name,
Name: name,
}, func() {
_, err := client.ExecForTests(ctx, fmt.Sprintf(`DROP STAGE "%s"`, name))
require.NoError(t, err)
}
}

func createStage(t *testing.T, client *sdk.Client, database *sdk.Database, schema *sdk.Schema, name string) (*sdk.Stage, func()) {
Expand Down Expand Up @@ -689,3 +690,15 @@ func createFileFormatWithOptions(t *testing.T, client *sdk.Client, schema sdk.Da
require.NoError(t, err)
}
}

func createView(t *testing.T, client *sdk.Client, viewId sdk.SchemaObjectIdentifier, asQuery string) func() {
t.Helper()
ctx := context.Background()
_, err := client.ExecForTests(ctx, fmt.Sprintf(`CREATE VIEW %s AS %s`, viewId.FullyQualifiedName(), asQuery))
require.NoError(t, err)

return func() {
_, err := client.ExecForTests(ctx, fmt.Sprintf(`DROP VIEW %s`, viewId.FullyQualifiedName()))
require.NoError(t, err)
}
}
Loading

0 comments on commit 5969b8e

Please sign in to comment.