-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Tasks v1 readiness - SDK part (#3086)
## Changes - Generated assertions for task - Added a few missing fields in Create, Alter, and outputs - Added CreateOrAlter support - Adjusted unit and integration tests - Adjusted validation generator a bit (It was panic-ing before for that case; it was never used before) - Adjusted resource and datasource to use new SDK ## References * [CREATE TASK](https://docs.snowflake.com/en/sql-reference/sql/create-task)
- Loading branch information
1 parent
a32f118
commit 0a77383
Showing
25 changed files
with
3,241 additions
and
858 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
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
74 changes: 74 additions & 0 deletions
74
pkg/acceptance/bettertestspoc/assert/objectassert/task_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,74 @@ | ||
package objectassert | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"reflect" | ||
"slices" | ||
"testing" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
) | ||
|
||
func (t *TaskAssert) HasNotEmptyCreatedOn() *TaskAssert { | ||
t.AddAssertion(func(t *testing.T, o *sdk.Task) error { | ||
t.Helper() | ||
if o.CreatedOn == "" { | ||
return fmt.Errorf("expected created on not empty; got: %v", o.CreatedOn) | ||
} | ||
return nil | ||
}) | ||
return t | ||
} | ||
|
||
func (t *TaskAssert) HasNotEmptyId() *TaskAssert { | ||
t.AddAssertion(func(t *testing.T, o *sdk.Task) error { | ||
t.Helper() | ||
if o.Id == "" { | ||
return fmt.Errorf("expected id not empty; got: %v", o.CreatedOn) | ||
} | ||
return nil | ||
}) | ||
return t | ||
} | ||
|
||
func (t *TaskAssert) HasPredecessors(ids ...sdk.SchemaObjectIdentifier) *TaskAssert { | ||
t.AddAssertion(func(t *testing.T, o *sdk.Task) error { | ||
t.Helper() | ||
if len(o.Predecessors) != len(ids) { | ||
return fmt.Errorf("expected %d (%v) predecessors, got %d (%v)", len(ids), ids, len(o.Predecessors), o.Predecessors) | ||
} | ||
var errs []error | ||
for _, id := range ids { | ||
if !slices.ContainsFunc(o.Predecessors, func(predecessorId sdk.SchemaObjectIdentifier) bool { | ||
return predecessorId.FullyQualifiedName() == id.FullyQualifiedName() | ||
}) { | ||
errs = append(errs, fmt.Errorf("expected id: %s, to be in the list of predecessors: %v", id.FullyQualifiedName(), o.Predecessors)) | ||
} | ||
} | ||
return errors.Join(errs...) | ||
}) | ||
return t | ||
} | ||
|
||
func (t *TaskAssert) HasTaskRelations(expected sdk.TaskRelations) *TaskAssert { | ||
t.AddAssertion(func(t *testing.T, o *sdk.Task) error { | ||
t.Helper() | ||
if len(o.TaskRelations.Predecessors) != len(expected.Predecessors) { | ||
return fmt.Errorf("expected %d (%v) predecessors in task relations, got %d (%v)", len(expected.Predecessors), expected.Predecessors, len(o.TaskRelations.Predecessors), o.TaskRelations.Predecessors) | ||
} | ||
var errs []error | ||
for _, id := range expected.Predecessors { | ||
if !slices.ContainsFunc(o.TaskRelations.Predecessors, func(predecessorId sdk.SchemaObjectIdentifier) bool { | ||
return predecessorId.FullyQualifiedName() == id.FullyQualifiedName() | ||
}) { | ||
errs = append(errs, fmt.Errorf("expected id: %s, to be in the list of predecessors in task relations: %v", id.FullyQualifiedName(), o.TaskRelations.Predecessors)) | ||
} | ||
} | ||
if !reflect.DeepEqual(expected.FinalizerTask, o.TaskRelations.FinalizerTask) { | ||
errs = append(errs, fmt.Errorf("expected finalizer task: %v; got: %v", expected.FinalizerTask, o.TaskRelations.FinalizerTask)) | ||
} | ||
return errors.Join(errs...) | ||
}) | ||
return t | ||
} |
251 changes: 251 additions & 0 deletions
251
pkg/acceptance/bettertestspoc/assert/objectassert/task_snowflake_gen.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.