Skip to content

Commit 5457f86

Browse files
committed
fix: allow safe creation of prerequired resources by not providing invalid parent
In order to create a certain resource, other resources might need to be in place first. The TestSuiteConfig's Create method should allow the developer to satisfy this precondition. If the precondition requires creating resources from the same parent as the target resource, we should not pass them an invalid parent. An invalid parent could fail the creation of the prerequired resources, thus preventing the precondition for the test to be reached.
1 parent a55aa2b commit 5457f86

20 files changed

+84
-66
lines changed

internal/aiptest/create/parent_invalid.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var parentInvalid = suite.Test{
2828
util.MethodCreate{
2929
Resource: scope.Resource,
3030
Method: createMethod,
31+
Message: "fx.Create(fx.nextParent(t, false))",
3132
Parent: strconv.Quote("invalid resource name"),
3233
}.Generate(f, "_", "err", ":=")
3334
f.P(ident.AssertEqual, "(t, ", ident.Codes(codes.InvalidArgument), ", ", ident.StatusCode, "(err), err)")

internal/aiptest/create/parent_missing.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var parentMissing = suite.Test{
2828
util.MethodCreate{
2929
Resource: scope.Resource,
3030
Method: createMethod,
31+
Message: "fx.Create(fx.nextParent(t, false))",
3132
Parent: strconv.Quote(""),
3233
}.Generate(f, "_", "err", ":=")
3334
f.P(ident.AssertEqual, "(t, ", ident.Codes(codes.InvalidArgument), ", ", ident.StatusCode, "(err), err)")

proto/gen/einride/example/freight/v1/freight_service_aiptest.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/gen/googleapis/area120/tables/v1alpha1/tables_aiptest.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/gen/googleapis/cloud/aiplatform/v1/dataset_service_aiptest.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/gen/googleapis/cloud/aiplatform/v1/endpoint_service_aiptest.pb.go

Lines changed: 18 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/gen/googleapis/cloud/aiplatform/v1/featurestore_service_aiptest.pb.go

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/gen/googleapis/cloud/aiplatform/v1/index_endpoint_service_aiptest.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/gen/googleapis/cloud/aiplatform/v1/index_service_aiptest.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/gen/googleapis/cloud/aiplatform/v1/job_service_aiptest.pb.go

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/gen/googleapis/cloud/aiplatform/v1/metadata_service_aiptest.pb.go

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)