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 Jan 9, 2024
1 parent fb61f84 commit 033b7bb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions pkg/sdk/testint/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ func useWarehouse(t *testing.T, client *sdk.Client, warehouseID sdk.AccountObjec

func createDatabase(t *testing.T, client *sdk.Client) (*sdk.Database, func()) {
t.Helper()
return createDatabaseWithOptions(t, client, sdk.RandomAccountObjectIdentifier(), testSchema(t).ID(), &sdk.CreateDatabaseOptions{})
return createDatabaseWithOptions(t, client, sdk.RandomAccountObjectIdentifier(), &sdk.CreateDatabaseOptions{})
}

func createDatabaseWithOptions(t *testing.T, client *sdk.Client, id sdk.AccountObjectIdentifier, useSchemaAfterDatabaseDrop sdk.DatabaseObjectIdentifier, opts *sdk.CreateDatabaseOptions) (*sdk.Database, func()) {
func createDatabaseWithOptions(t *testing.T, client *sdk.Client, id sdk.AccountObjectIdentifier, opts *sdk.CreateDatabaseOptions) (*sdk.Database, func()) {
t.Helper()
ctx := context.Background()
err := client.Databases.Create(ctx, id, opts)
Expand All @@ -60,7 +60,7 @@ func createDatabaseWithOptions(t *testing.T, client *sdk.Client, id sdk.AccountO
return database, func() {
err := client.Databases.Drop(ctx, id, nil)
require.NoError(t, err)
err = client.Sessions.UseSchema(ctx, useSchemaAfterDatabaseDrop)
err = client.Sessions.UseSchema(ctx, sdk.NewDatabaseObjectIdentifier(TestDatabaseName, TestSchemaName))
require.NoError(t, err)
}
}
Expand Down
17 changes: 10 additions & 7 deletions pkg/sdk/testint/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const (
secondaryAccountProfile = "secondary_test_account"
)

var (
TestWarehouseName = "int_test_wh_" + random.UUID()
TestDatabaseName = "int_test_db_" + random.UUID()
TestSchemaName = "int_test_sc_" + random.UUID()
)

var itc integrationTestContext

func TestMain(m *testing.M) {
Expand Down Expand Up @@ -146,8 +152,7 @@ func (itc *integrationTestContext) initialize() error {
}

func createDb(client *sdk.Client, ctx context.Context) (*sdk.Database, func(), error) {
name := "int_test_db_" + random.UUID()
id := sdk.NewAccountObjectIdentifier(name)
id := sdk.NewAccountObjectIdentifier(TestDatabaseName)
err := client.Databases.Create(ctx, id, nil)
if err != nil {
return nil, nil, err
Expand All @@ -159,21 +164,19 @@ func createDb(client *sdk.Client, ctx context.Context) (*sdk.Database, func(), e
}

func createSc(client *sdk.Client, ctx context.Context, db *sdk.Database) (*sdk.Schema, func(), error) {
name := "int_test_sc_" + random.UUID()
id := sdk.NewDatabaseObjectIdentifier(db.Name, name)
id := sdk.NewDatabaseObjectIdentifier(db.Name, TestSchemaName)
err := client.Schemas.Create(ctx, id, nil)
if err != nil {
return nil, nil, err
}
schema, err := client.Schemas.ShowByID(ctx, sdk.NewDatabaseObjectIdentifier(db.Name, name))
schema, err := client.Schemas.ShowByID(ctx, sdk.NewDatabaseObjectIdentifier(db.Name, TestSchemaName))
return schema, func() {
_ = client.Schemas.Drop(ctx, id, nil)
}, err
}

func createWh(client *sdk.Client, ctx context.Context) (*sdk.Warehouse, func(), error) {
name := "int_test_wh_" + random.UUID()
id := sdk.NewAccountObjectIdentifier(name)
id := sdk.NewAccountObjectIdentifier(TestWarehouseName)
err := client.Warehouses.Create(ctx, id, nil)
if err != nil {
return nil, nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/testint/shares_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func TestInt_SharesAlter(t *testing.T) {
})

t.Run("set accounts", func(t *testing.T) {
db, dbCleanup := createDatabaseWithOptions(t, secondaryClient, sdk.RandomAccountObjectIdentifier(), testSchema(t).ID(), nil)
db, dbCleanup := createDatabase(t, secondaryClient)
t.Cleanup(dbCleanup)

shareTest, shareCleanup := createShare(t, secondaryClient)
Expand Down Expand Up @@ -372,7 +372,7 @@ func TestInt_ShareDescribeConsumer(t *testing.T) {
consumerClient := testClient(t)

t.Run("describe share", func(t *testing.T) {
db, dbCleanup := createDatabaseWithOptions(t, providerClient, sdk.RandomAccountObjectIdentifier(), testSchema(t).ID(), nil)
db, dbCleanup := createDatabase(t, providerClient)
t.Cleanup(dbCleanup)

shareTest, shareCleanup := createShare(t, providerClient)
Expand Down

0 comments on commit 033b7bb

Please sign in to comment.