-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into bcr-update
- Loading branch information
Showing
88 changed files
with
1,406 additions
and
964 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" | ||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type AlertClient struct { | ||
context *TestClientContext | ||
} | ||
|
||
func NewAlertClient(context *TestClientContext) *AlertClient { | ||
return &AlertClient{ | ||
context: context, | ||
} | ||
} | ||
|
||
func (c *AlertClient) client() sdk.Alerts { | ||
return c.context.client.Alerts | ||
} | ||
|
||
func (c *AlertClient) CreateAlert(t *testing.T) (*sdk.Alert, func()) { | ||
t.Helper() | ||
schedule := "USING CRON * * * * * UTC" | ||
condition := "SELECT 1" | ||
action := "SELECT 1" | ||
return c.CreateAlertWithOptions(t, schedule, condition, action, &sdk.CreateAlertOptions{}) | ||
} | ||
|
||
func (c *AlertClient) CreateAlertWithOptions(t *testing.T, schedule string, condition string, action string, opts *sdk.CreateAlertOptions) (*sdk.Alert, func()) { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
name := random.String() | ||
id := c.context.newSchemaObjectIdentifier(name) | ||
|
||
err := c.client().Create(ctx, id, c.context.warehouseId(), schedule, condition, action, opts) | ||
require.NoError(t, err) | ||
|
||
alert, err := c.client().ShowByID(ctx, id) | ||
require.NoError(t, err) | ||
|
||
return alert, c.DropAlertFunc(t, id) | ||
} | ||
|
||
func (c *AlertClient) DropAlertFunc(t *testing.T, id sdk.SchemaObjectIdentifier) func() { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
return func() { | ||
err := c.client().Drop(ctx, id, &sdk.DropAlertOptions{IfExists: sdk.Bool(true)}) | ||
require.NoError(t, err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" | ||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type ApplicationClient struct { | ||
context *TestClientContext | ||
} | ||
|
||
func NewApplicationClient(context *TestClientContext) *ApplicationClient { | ||
return &ApplicationClient{ | ||
context: context, | ||
} | ||
} | ||
|
||
func (c *ApplicationClient) client() sdk.Applications { | ||
return c.context.client.Applications | ||
} | ||
|
||
func (c *ApplicationClient) CreateApplication(t *testing.T, packageId sdk.AccountObjectIdentifier, version string) (*sdk.Application, func()) { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
id := sdk.NewAccountObjectIdentifier(random.AlphaN(8)) | ||
err := c.client().Create(ctx, sdk.NewCreateApplicationRequest(id, packageId).WithVersion(sdk.NewApplicationVersionRequest().WithVersionAndPatch(sdk.NewVersionAndPatchRequest(version, nil)))) | ||
require.NoError(t, err) | ||
|
||
application, err := c.client().ShowByID(ctx, id) | ||
require.NoError(t, err) | ||
|
||
return application, c.DropApplicationFunc(t, id) | ||
} | ||
|
||
func (c *ApplicationClient) DropApplicationFunc(t *testing.T, id sdk.AccountObjectIdentifier) func() { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
return func() { | ||
err := c.client().Drop(ctx, sdk.NewDropApplicationRequest(id).WithIfExists(sdk.Bool(true))) | ||
require.NoError(t, err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" | ||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type ApplicationPackageClient struct { | ||
context *TestClientContext | ||
} | ||
|
||
func NewApplicationPackageClient(context *TestClientContext) *ApplicationPackageClient { | ||
return &ApplicationPackageClient{ | ||
context: context, | ||
} | ||
} | ||
|
||
func (c *ApplicationPackageClient) client() sdk.ApplicationPackages { | ||
return c.context.client.ApplicationPackages | ||
} | ||
|
||
func (c *ApplicationPackageClient) CreateApplicationPackage(t *testing.T) (*sdk.ApplicationPackage, func()) { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
id := sdk.NewAccountObjectIdentifier(random.AlphaN(8)) | ||
err := c.client().Create(ctx, sdk.NewCreateApplicationPackageRequest(id)) | ||
require.NoError(t, err) | ||
|
||
applicationPackage, err := c.client().ShowByID(ctx, id) | ||
require.NoError(t, err) | ||
|
||
return applicationPackage, c.DropApplicationPackageFunc(t, id) | ||
} | ||
|
||
func (c *ApplicationPackageClient) DropApplicationPackageFunc(t *testing.T, id sdk.AccountObjectIdentifier) func() { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
return func() { | ||
err := c.client().Drop(ctx, sdk.NewDropApplicationPackageRequest(id).WithIfExists(sdk.Bool(true))) | ||
require.NoError(t, err) | ||
} | ||
} | ||
|
||
func (c *ApplicationPackageClient) AddApplicationPackageVersion(t *testing.T, id sdk.AccountObjectIdentifier, stageId sdk.SchemaObjectIdentifier, versionName string) { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
using := "@" + stageId.FullyQualifiedName() | ||
|
||
err := c.client().Alter(ctx, sdk.NewAlterApplicationPackageRequest(id).WithAddVersion(sdk.NewAddVersionRequest(using).WithVersionIdentifier(sdk.String(versionName)))) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" | ||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type DynamicTableClient struct { | ||
context *TestClientContext | ||
} | ||
|
||
func NewDynamicTableClient(context *TestClientContext) *DynamicTableClient { | ||
return &DynamicTableClient{ | ||
context: context, | ||
} | ||
} | ||
|
||
func (c *DynamicTableClient) client() sdk.DynamicTables { | ||
return c.context.client.DynamicTables | ||
} | ||
|
||
func (c *DynamicTableClient) CreateDynamicTable(t *testing.T, tableId sdk.SchemaObjectIdentifier) (*sdk.DynamicTable, func()) { | ||
t.Helper() | ||
return c.CreateDynamicTableWithOptions(t, c.context.schemaId(), random.AlphaN(12), c.context.warehouseId(), tableId) | ||
} | ||
|
||
func (c *DynamicTableClient) CreateDynamicTableWithOptions(t *testing.T, schemaId sdk.DatabaseObjectIdentifier, name string, warehouseId sdk.AccountObjectIdentifier, tableId sdk.SchemaObjectIdentifier) (*sdk.DynamicTable, func()) { | ||
t.Helper() | ||
id := sdk.NewSchemaObjectIdentifier(schemaId.DatabaseName(), schemaId.Name(), name) | ||
targetLag := sdk.TargetLag{ | ||
MaximumDuration: sdk.String("2 minutes"), | ||
} | ||
query := fmt.Sprintf(`select "ID" from %s`, tableId.FullyQualifiedName()) | ||
comment := random.Comment() | ||
ctx := context.Background() | ||
|
||
err := c.client().Create(ctx, sdk.NewCreateDynamicTableRequest(id, warehouseId, targetLag, query).WithComment(&comment)) | ||
require.NoError(t, err) | ||
|
||
dynamicTable, err := c.client().ShowByID(ctx, id) | ||
require.NoError(t, err) | ||
|
||
return dynamicTable, c.DropDynamicTableFunc(t, id) | ||
} | ||
|
||
func (c *DynamicTableClient) DropDynamicTableFunc(t *testing.T, id sdk.SchemaObjectIdentifier) func() { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
return func() { | ||
err := c.client().Drop(ctx, sdk.NewDropDynamicTableRequest(id).WithIfExists(true)) | ||
require.NoError(t, err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type FailoverGroupClient struct { | ||
context *TestClientContext | ||
} | ||
|
||
func NewFailoverGroupClient(context *TestClientContext) *FailoverGroupClient { | ||
return &FailoverGroupClient{ | ||
context: context, | ||
} | ||
} | ||
|
||
func (c *FailoverGroupClient) client() sdk.FailoverGroups { | ||
return c.context.client.FailoverGroups | ||
} | ||
|
||
func (c *FailoverGroupClient) CreateFailoverGroup(t *testing.T) (*sdk.FailoverGroup, func()) { | ||
t.Helper() | ||
objectTypes := []sdk.PluralObjectType{sdk.PluralObjectTypeRoles} | ||
currentAccount, err := c.context.client.ContextFunctions.CurrentAccount(context.Background()) | ||
require.NoError(t, err) | ||
accountID := sdk.NewAccountIdentifierFromAccountLocator(currentAccount) | ||
allowedAccounts := []sdk.AccountIdentifier{accountID} | ||
return c.CreateFailoverGroupWithOptions(t, objectTypes, allowedAccounts, nil) | ||
} | ||
|
||
func (c *FailoverGroupClient) CreateFailoverGroupWithOptions(t *testing.T, objectTypes []sdk.PluralObjectType, allowedAccounts []sdk.AccountIdentifier, opts *sdk.CreateFailoverGroupOptions) (*sdk.FailoverGroup, func()) { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
id := sdk.RandomAlphanumericAccountObjectIdentifier() | ||
|
||
err := c.client().Create(ctx, id, objectTypes, allowedAccounts, opts) | ||
require.NoError(t, err) | ||
|
||
failoverGroup, err := c.client().ShowByID(ctx, id) | ||
require.NoError(t, err) | ||
|
||
return failoverGroup, c.DropFailoverGroupFunc(t, id) | ||
} | ||
|
||
func (c *FailoverGroupClient) DropFailoverGroupFunc(t *testing.T, id sdk.AccountObjectIdentifier) func() { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
return func() { | ||
err := c.client().Drop(ctx, id, &sdk.DropFailoverGroupOptions{IfExists: sdk.Bool(true)}) | ||
require.NoError(t, err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" | ||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type FileFormatClient struct { | ||
context *TestClientContext | ||
} | ||
|
||
func NewFileFormatClient(context *TestClientContext) *FileFormatClient { | ||
return &FileFormatClient{ | ||
context: context, | ||
} | ||
} | ||
|
||
func (c *FileFormatClient) client() sdk.FileFormats { | ||
return c.context.client.FileFormats | ||
} | ||
|
||
func (c *FileFormatClient) CreateFileFormat(t *testing.T) (*sdk.FileFormat, func()) { | ||
t.Helper() | ||
return c.CreateFileFormatWithOptions(t, &sdk.CreateFileFormatOptions{ | ||
Type: sdk.FileFormatTypeCSV, | ||
}) | ||
} | ||
|
||
func (c *FileFormatClient) CreateFileFormatWithOptions(t *testing.T, opts *sdk.CreateFileFormatOptions) (*sdk.FileFormat, func()) { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
id := c.context.newSchemaObjectIdentifier(random.AlphanumericN(12)) | ||
|
||
err := c.client().Create(ctx, id, opts) | ||
require.NoError(t, err) | ||
|
||
fileFormat, err := c.client().ShowByID(ctx, id) | ||
require.NoError(t, err) | ||
|
||
return fileFormat, c.DropFileFormatFunc(t, id) | ||
} | ||
|
||
func (c *FileFormatClient) DropFileFormatFunc(t *testing.T, id sdk.SchemaObjectIdentifier) func() { | ||
t.Helper() | ||
ctx := context.Background() | ||
|
||
return func() { | ||
err := c.client().Drop(ctx, id, &sdk.DropFileFormatOptions{IfExists: sdk.Bool(true)}) | ||
require.NoError(t, err) | ||
} | ||
} |
Oops, something went wrong.