-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Tasks v1 readiness - SDK part #3086
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
39c6bcf
wip
sfc-gh-jcieslak fff9b1e
wip
sfc-gh-jcieslak 110d00a
Passing tests
sfc-gh-jcieslak 59d2fa4
Added create or alter test
sfc-gh-jcieslak 1224a7d
wip
sfc-gh-jcieslak 56b338b
wip
sfc-gh-jcieslak e076055
wip
sfc-gh-jcieslak 5e808d1
wip
sfc-gh-jcieslak 65ece76
changes after review
sfc-gh-jcieslak 554fc90
changes after review
sfc-gh-jcieslak 87638ea
lint fix
sfc-gh-jcieslak a783bec
Changes after review
sfc-gh-jcieslak fc5586e
Changes after review
sfc-gh-jcieslak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
69 changes: 69 additions & 0 deletions
69
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,69 @@ | ||
package objectassert | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"reflect" | ||
"slices" | ||
"testing" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
) | ||
|
||
func (w *TaskAssert) HasNotEmptyCreatedOn() *TaskAssert { | ||
w.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 w | ||
} | ||
|
||
func (w *TaskAssert) HasNotEmptyId() *TaskAssert { | ||
w.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 w | ||
} | ||
|
||
func (w *TaskAssert) HasPredecessors(ids ...sdk.SchemaObjectIdentifier) *TaskAssert { | ||
w.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 w | ||
} | ||
|
||
func (t *TaskAssert) HasTaskRelations(expected sdk.TaskRelations) *TaskAssert { | ||
t.AddAssertion(func(t *testing.T, o *sdk.Task) error { | ||
t.Helper() | ||
if slices.EqualFunc(o.TaskRelations.Predecessors, expected.Predecessors, func(id sdk.SchemaObjectIdentifier, id2 sdk.SchemaObjectIdentifier) bool { | ||
return id.FullyQualifiedName() == id2.FullyQualifiedName() | ||
}) { | ||
return fmt.Errorf("expected task predecessors: %v; got: %v", expected.Predecessors, o.TaskRelations.Predecessors) | ||
} | ||
|
||
if !reflect.DeepEqual(expected.FinalizerTask, o.TaskRelations.FinalizerTask) { | ||
return fmt.Errorf("expected finalizer task: %v; got: %v", expected.FinalizerTask, o.TaskRelations.FinalizerTask) | ||
} | ||
return nil | ||
}) | ||
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.
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about a different order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't really matter, we only care are about expected ids being there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but they can be returned in a different order. Please use ElementsMatch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how testify package works with our package, so I rewrote checks to be similar to the assert above (it asserts predecessors, but in the Predecessors field).