generated from pulumi/pulumi-tf-provider-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pulumi/pulumi-terraform-bridge#1849 This PR adds tests for the following resources: index_accountgrant index_fileformat index_rolegrants index_role index_grantprivilegestorole index_schema index_user index_schemagrant index_databasegrant index_task index_table index_database index_tablegrant
- Loading branch information
1 parent
301165b
commit 52cce51
Showing
34 changed files
with
544 additions
and
1 deletion.
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
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
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,131 @@ | ||
//go:build !go && !nodejs && !python && !dotnet | ||
// +build !go,!nodejs,!python,!dotnet | ||
|
||
package snowflake | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/pulumi/providertest" | ||
"github.com/pulumi/providertest/optproviderupgrade" | ||
"github.com/pulumi/providertest/pulumitest" | ||
"github.com/pulumi/providertest/pulumitest/assertpreview" | ||
"github.com/pulumi/providertest/pulumitest/opttest" | ||
"github.com/pulumi/pulumi/sdk/v3/go/auto" | ||
) | ||
|
||
const providerName = "snowflake" | ||
const defaultBaselineVersion = "0.50.2" | ||
|
||
var programs = []string{ | ||
"test-programs/index_accountgrant", | ||
"test-programs/index_fileformat", | ||
"test-programs/index_rolegrants", | ||
"test-programs/index_role", | ||
"test-programs/index_grantprivilegestorole", | ||
"test-programs/index_schema", | ||
"test-programs/index_user", | ||
"test-programs/index_schemagrant", | ||
"test-programs/index_databasegrant", | ||
"test-programs/index_task", | ||
"test-programs/index_table", | ||
"test-programs/index_database", | ||
"test-programs/index_tablegrant", | ||
} | ||
|
||
func TestUpgradeCoverage(t *testing.T) { | ||
providertest.ReportUpgradeCoverage(t) | ||
} | ||
|
||
type UpgradeTestOpts struct { | ||
baselineVersion string | ||
assertFunc func(*testing.T, auto.PreviewResult) | ||
config map[string]string | ||
} | ||
|
||
func WithBaselineVersion(baselineVersion string) func(opts *UpgradeTestOpts) { | ||
return func(opts *UpgradeTestOpts) { | ||
opts.baselineVersion = baselineVersion | ||
} | ||
} | ||
|
||
func WithAssertFunc(assertFunc func(*testing.T, auto.PreviewResult)) func(opts *UpgradeTestOpts) { | ||
return func(opts *UpgradeTestOpts) { | ||
opts.assertFunc = assertFunc | ||
} | ||
} | ||
|
||
func WithConfig(config map[string]string) func(opts *UpgradeTestOpts) { | ||
return func(opts *UpgradeTestOpts) { | ||
opts.config = config | ||
} | ||
} | ||
func testProviderUpgrade(t *testing.T, dir string, opts ...func(*UpgradeTestOpts)) { | ||
options := &UpgradeTestOpts{} | ||
for _, o := range opts { | ||
o(options) | ||
} | ||
testProviderUpgradeWithOpts(t, dir, options.baselineVersion, options.config, options.assertFunc) | ||
} | ||
|
||
func testProviderUpgradeWithOpts( | ||
t *testing.T, dir, baselineVersion string, config map[string]string, | ||
assertFunction func(*testing.T, auto.PreviewResult), | ||
) { | ||
if testing.Short() { | ||
t.Skipf("Skipping in testing.Short() mode, assuming this is a CI run without credentials") | ||
} | ||
cwd, err := os.Getwd() | ||
require.NoError(t, err) | ||
if baselineVersion == "" { | ||
baselineVersion = defaultBaselineVersion | ||
} | ||
test := pulumitest.NewPulumiTest(t, dir, | ||
opttest.DownloadProviderVersion(providerName, baselineVersion), | ||
opttest.LocalProviderPath(providerName, filepath.Join(cwd, "..", "bin")), | ||
) | ||
for k, v := range config { | ||
test.SetConfig(k, v) | ||
} | ||
result := providertest.PreviewProviderUpgrade(test, providerName, baselineVersion, optproviderupgrade.DisableAttach()) | ||
if assertFunction != nil { | ||
assertFunction(t, result) | ||
} else { | ||
assertpreview.HasNoReplacements(t, result) | ||
} | ||
} | ||
|
||
func testProgram(t *testing.T, dir string) { | ||
if testing.Short() { | ||
t.Skipf("Skipping in testing.Short() mode, assuming this is a CI run without credentials") | ||
} | ||
cwd, err := os.Getwd() | ||
require.NoError(t, err) | ||
t.Setenv("SNOWFLAKE_ROLE", "ACCOUNTADMIN") | ||
test := pulumitest.NewPulumiTest(t, dir, | ||
opttest.LocalProviderPath(providerName, filepath.Join(cwd, "..", "bin")), | ||
opttest.SkipInstall(), | ||
) | ||
test.Up() | ||
} | ||
|
||
func TestPrograms(t *testing.T) { | ||
for _, p := range programs { | ||
t.Run(p, func(t *testing.T) { | ||
testProgram(t, p) | ||
}) | ||
} | ||
} | ||
|
||
func TestProgramsUpgrade(t *testing.T) { | ||
t.Skipf("skip upgrade tests for now as we have not recorded them.") | ||
for _, p := range programs { | ||
t.Run(p, func(t *testing.T) { | ||
testProviderUpgrade(t, p) | ||
}) | ||
} | ||
} |
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,2 @@ | ||
|
||
/Pulumi.*.yaml |
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,19 @@ | ||
name: index_accountgrant9XOe6XgqziGU | ||
runtime: yaml | ||
description: "" | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: https://www.pulumi.com/ai/api/project/2ab84136-43fd-4765-bf92-3a68c1e9d5d7.zip | ||
outputs: | ||
accountGrantRole: ${exampleAccountGrant.roles[0]} | ||
roleName: ${exampleRole.name} | ||
resources: | ||
exampleAccountGrant: | ||
properties: | ||
privilege: CREATE DATABASE | ||
roles: | ||
- ${exampleRole.name} | ||
type: snowflake:AccountGrant | ||
exampleRole: | ||
type: snowflake:Role |
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,2 @@ | ||
|
||
/Pulumi.*.yaml |
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,42 @@ | ||
name: index_databaseK1w012UT8Wct | ||
runtime: yaml | ||
description: "" | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: https://www.pulumi.com/ai/api/project/b2e13122-42a0-4df7-8e80-1f75bde32c97.zip | ||
outputs: | ||
snowflakeDatabaseName: ${exampleDatabase.name} | ||
snowflakeRoleName: ${exampleRole.name} | ||
snowflakeSchemaName: ${exampleSchema.name} | ||
snowflakeUserName: ${exampleUser.name} | ||
snowflakeWarehouseName: ${exampleWarehouse.name} | ||
resources: | ||
exampleDatabase: | ||
type: snowflake:Database | ||
exampleGrant: | ||
properties: | ||
databaseName: ${exampleDatabase.name} | ||
roles: | ||
- ${exampleRole.name} | ||
type: snowflake:DatabaseGrant | ||
exampleRole: | ||
type: snowflake:Role | ||
exampleSchema: | ||
properties: | ||
database: ${exampleDatabase.name} | ||
type: snowflake:Schema | ||
exampleUser: | ||
properties: | ||
defaultRole: my_snowflake_role | ||
disabled: false | ||
displayName: Example User | ||
loginName: example_login | ||
type: snowflake:User | ||
exampleWarehouse: | ||
properties: | ||
autoResume: true | ||
autoSuspend: 300 | ||
maxClusterCount: 1 | ||
warehouseSize: X-SMALL | ||
type: snowflake:Warehouse |
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,2 @@ | ||
|
||
/Pulumi.*.yaml |
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,19 @@ | ||
name: index_databasegrantuauVxBfeFZz2 | ||
runtime: yaml | ||
description: "" | ||
config: | ||
pulumi:tags: | ||
value: | ||
pulumi:template: https://www.pulumi.com/ai/api/project/d009c937-2a66-4d6d-8d57-992e870e364e.zip | ||
resources: | ||
myDatabase: | ||
type: snowflake:Database | ||
myDatabaseGrant: | ||
properties: | ||
databaseName: ${myDatabase.name} | ||
privilege: USAGE | ||
roles: | ||
- ${myRole.name} | ||
type: snowflake:DatabaseGrant | ||
myRole: | ||
type: snowflake:Role |
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,2 @@ | ||
|
||
/Pulumi.*.yaml |
Oops, something went wrong.