From ed1251592b98654e893e6603f4492bdfdad5b3c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Cie=C5=9Blak?= Date: Wed, 13 Nov 2024 10:05:29 +0100 Subject: [PATCH] wip --- .../task_resource_parameters_ext.go | 16 ++++++++++++++-- pkg/datasources/tasks_acceptance_test.go | 6 +++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pkg/acceptance/bettertestspoc/assert/resourceparametersassert/task_resource_parameters_ext.go b/pkg/acceptance/bettertestspoc/assert/resourceparametersassert/task_resource_parameters_ext.go index 45a2def403..96ff259ffe 100644 --- a/pkg/acceptance/bettertestspoc/assert/resourceparametersassert/task_resource_parameters_ext.go +++ b/pkg/acceptance/bettertestspoc/assert/resourceparametersassert/task_resource_parameters_ext.go @@ -1,11 +1,23 @@ package resourceparametersassert import ( - "strings" - + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" + "strings" + "testing" ) +// TaskDatasourceParameters is a temporary workaround to have better parameter assertions in data source acceptance tests. +func TaskDatasourceParameters(t *testing.T, name string) *TaskResourceParametersAssert { + t.Helper() + + taskAssert := TaskResourceParametersAssert{ + ResourceAssert: assert.NewDatasourceAssert("data."+name, "parameters", "tasks.0."), + } + taskAssert.AddAssertion(assert.ValueSet("parameters.#", "1")) + return &taskAssert +} + func (u *TaskResourceParametersAssert) HasAllDefaults() *TaskResourceParametersAssert { return u. HasSuspendTaskAfterNumFailures(10). diff --git a/pkg/datasources/tasks_acceptance_test.go b/pkg/datasources/tasks_acceptance_test.go index c4adcaac12..a21f76af55 100644 --- a/pkg/datasources/tasks_acceptance_test.go +++ b/pkg/datasources/tasks_acceptance_test.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert/resourceparametersassert" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert/resourceshowoutputassert" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" @@ -68,7 +69,8 @@ func TestAcc_Tasks_Like_RootTask(t *testing.T) { HasBudget(""). HasTaskRelations(sdk.TaskRelations{}). HasLastSuspendedReason(""), - // TODO: Parameters + resourceparametersassert.TaskDatasourceParameters(t, "snowflake_tasks.test"). + HasAllDefaults(), ), }, { @@ -161,12 +163,14 @@ func TestAcc_Tasks_Limit(t *testing.T) { tfversion.RequireAbove(tfversion.Version1_5_0), }, Steps: []resource.TestStep{ + // Limit with prefix { Config: taskDatasourceLimitWithPrefix(2, prefix), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.snowflake_tasks.test", "tasks.#", "2"), ), }, + // Only limit { Config: taskDatasourceLimit(1), Check: resource.ComposeTestCheckFunc(