Skip to content

Commit 23725df

Browse files
chore: Adjust data source tests follow up 2 (snowflakedb#4165)
Follow up for snowflakedb#4115, addressing the following data sources - `secrets` - `security integrations` - `streamlits` - `schemas`
1 parent 8e1d20a commit 23725df

13 files changed

+898
-939
lines changed

pkg/acceptance/bettertestspoc/assert/objectassert/gen/sdk_object_def.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ var allStructs = []SdkObjectDef{
173173
ObjectType: sdk.ObjectTypeSecurityIntegration,
174174
ObjectStruct: sdk.SecurityIntegration{},
175175
},
176+
{
177+
IdType: "sdk.DatabaseObjectIdentifier",
178+
ObjectType: sdk.ObjectTypeSchema,
179+
ObjectStruct: sdk.Schema{},
180+
},
176181
{
177182
IdType: "sdk.SchemaObjectIdentifier",
178183
ObjectType: sdk.ObjectTypeStreamlit,

pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/schema_show_output_ext.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ func (s *SchemaShowOutputAssert) HasOwnerNotEmpty() *SchemaShowOutputAssert {
1414
return s
1515
}
1616

17+
func (s *SchemaShowOutputAssert) HasRetentionTimeNotEmpty() *SchemaShowOutputAssert {
18+
s.AddAssertion(assert.ResourceShowOutputValuePresent("retention_time"))
19+
return s
20+
}
21+
1722
func (s *SchemaShowOutputAssert) HasOwnerRoleTypeNotEmpty() *SchemaShowOutputAssert {
1823
s.AddAssertion(assert.ResourceShowOutputValuePresent("owner_role_type"))
1924
return s
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package resourceshowoutputassert
2+
3+
import (
4+
"testing"
5+
6+
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert"
7+
)
8+
9+
func SchemasDatasourceShowOutput(t *testing.T, datasourceReference string) *SchemaShowOutputAssert {
10+
t.Helper()
11+
12+
s := SchemaShowOutputAssert{
13+
ResourceAssert: assert.NewDatasourceAssert(datasourceReference, "show_output", "schemas.0."),
14+
}
15+
s.AddAssertion(assert.ValueSet("show_output.#", "1"))
16+
return &s
17+
}

pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/secrets_datasource_show_output_ext.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import (
77
)
88

99
// SecretsDatasourceShowOutput is a temporary workaround to have better show output assertions in data source acceptance tests.
10-
func SecretsDatasourceShowOutput(t *testing.T, name string) *SecretShowOutputAssert {
10+
func SecretsDatasourceShowOutput(t *testing.T, datasourceReference string) *SecretShowOutputAssert {
1111
t.Helper()
1212

1313
s := SecretShowOutputAssert{
14-
ResourceAssert: assert.NewDatasourceAssert("data."+name, "show_output", "secrets.0."),
14+
ResourceAssert: assert.NewDatasourceAssert(datasourceReference, "show_output", "secrets.0."),
1515
}
1616
s.AddAssertion(assert.ValueSet("show_output.#", "1"))
1717
return &s
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package resourceshowoutputassert
2+
3+
import "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert"
4+
5+
func (s *SecurityIntegrationShowOutputAssert) HasCreatedOnNotEmpty() *SecurityIntegrationShowOutputAssert {
6+
s.AddAssertion(assert.ValuePresent("show_output.0.created_on"))
7+
return s
8+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package resourceshowoutputassert
2+
3+
import (
4+
"testing"
5+
6+
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert"
7+
)
8+
9+
func SecurityIntegrationsDatasourceShowOutput(t *testing.T, datasourceReference string) *SecurityIntegrationShowOutputAssert {
10+
t.Helper()
11+
s := SecurityIntegrationShowOutputAssert{
12+
ResourceAssert: assert.NewDatasourceAssert(datasourceReference, "show_output", "security_integrations.0."),
13+
}
14+
s.AddAssertion(assert.ValueSet("show_output.#", "1"))
15+
return &s
16+
}

pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert/streamlit_show_output_ext.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ func (s *StreamlitShowOutputAssert) HasUrlIdNotEmpty() *StreamlitShowOutputAsser
1313
s.AddAssertion(assert.ResourceShowOutputValuePresent("url_id"))
1414
return s
1515
}
16+
17+
func (s *StreamlitShowOutputAssert) HasOwnerNotEmpty() *StreamlitShowOutputAssert {
18+
s.AddAssertion(assert.ResourceShowOutputValuePresent("owner"))
19+
return s
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package resourceshowoutputassert
2+
3+
import (
4+
"testing"
5+
6+
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert"
7+
)
8+
9+
func StreamlitsDatasourceShowOutput(t *testing.T, datasourceReference string) *StreamlitShowOutputAssert {
10+
t.Helper()
11+
12+
s := StreamlitShowOutputAssert{
13+
ResourceAssert: assert.NewDatasourceAssert(datasourceReference, "show_output", "streamlits.0."),
14+
}
15+
s.AddAssertion(assert.ValueSet("show_output.#", "1"))
16+
return &s
17+
}

pkg/acceptance/bettertestspoc/config/datasourcemodel/streamlits_model_ext.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ func (s *StreamlitsModel) WithInDatabase(databaseId sdk.AccountObjectIdentifier)
1313
}),
1414
)
1515
}
16+
17+
func (s *StreamlitsModel) WithInSchema(schemaId sdk.DatabaseObjectIdentifier) *StreamlitsModel {
18+
return s.WithInValue(
19+
tfconfig.ObjectVariable(map[string]tfconfig.Variable{
20+
"schema": tfconfig.StringVariable(schemaId.FullyQualifiedName()),
21+
}),
22+
)
23+
}

pkg/testacc/data_source_schemas_acceptance_test.go

Lines changed: 126 additions & 108 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)