-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add database describe object assertions
- Loading branch information
1 parent
260351a
commit a8256e5
Showing
5 changed files
with
68 additions
and
54 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
pkg/acceptance/bettertestspoc/assert/objectassert/describe_database_snowflake_ext.go
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,46 @@ | ||
package objectassert | ||
|
||
import ( | ||
"fmt" | ||
"slices" | ||
"testing" | ||
|
||
acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" | ||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
) | ||
|
||
// TODO [SNOW-1501905]: this file should be fully regenerated when adding and option to assert the results of describe | ||
type DatabaseDescribeAssert struct { | ||
*assert.SnowflakeObjectAssert[sdk.DatabaseDetails, sdk.AccountObjectIdentifier] | ||
} | ||
|
||
func DatabaseDescribe(t *testing.T, id sdk.AccountObjectIdentifier) *DatabaseDescribeAssert { | ||
t.Helper() | ||
return &DatabaseDescribeAssert{ | ||
assert.NewSnowflakeObjectAssertWithProvider(sdk.ObjectType("DATABASE_DETAILS"), id, acc.TestClient().Database.Describe), | ||
} | ||
} | ||
|
||
func (d *DatabaseDescribeAssert) DoesNotContainPublicSchema() *DatabaseDescribeAssert { | ||
d.AddAssertion(func(t *testing.T, o *sdk.DatabaseDetails) error { | ||
t.Helper() | ||
if slices.ContainsFunc(o.Rows, func(row sdk.DatabaseDetailsRow) bool { return row.Name == "PUBLIC" && row.Kind == "SCHEMA" }) { | ||
return fmt.Errorf("expected database %s to not contain public schema", d.GetId()) | ||
} | ||
return nil | ||
}) | ||
return d | ||
} | ||
|
||
func (d *DatabaseDescribeAssert) ContainsPublicSchema() *DatabaseDescribeAssert { | ||
d.AddAssertion(func(t *testing.T, o *sdk.DatabaseDetails) error { | ||
t.Helper() | ||
if !slices.ContainsFunc(o.Rows, func(row sdk.DatabaseDetailsRow) bool { return row.Name == "PUBLIC" && row.Kind == "SCHEMA" }) { | ||
return fmt.Errorf("expected database %s to contain public schema", d.GetId()) | ||
} | ||
return nil | ||
}) | ||
return d | ||
} |
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 was deleted.
Oops, something went wrong.
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