-
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.
- Loading branch information
1 parent
6691209
commit cd972d2
Showing
8 changed files
with
903 additions
and
92 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
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,68 @@ | ||
package objectassert | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
"reflect" | ||
"slices" | ||
"testing" | ||
) | ||
|
||
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.
Oops, something went wrong.