Skip to content

Commit

Permalink
fix: Skip testNoChangeAfterUpdate if update resource is empty
Browse files Browse the repository at this point in the history
This issue was never hit before because testNoChangeAfterUpdate is
currently only enabled for SQLInstances resources. We recently added a
SQLInstance test case that does not set an update.yaml resource
(sqlinstance-clone-minimal), and it revealed the problem causing a nil
pointer dereference when getting update object.
  • Loading branch information
jasonvigil committed Sep 3, 2024
1 parent 404c035 commit af9b783
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/controller/dynamic/dynamic_controller_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,15 @@ func testNoChangeAfterCreate(ctx context.Context, t *testing.T, testContext test

// testNoChangeAfterUpdate is enabled only on resources allowlisted inside the function.
func testNoChangeAfterUpdate(ctx context.Context, t *testing.T, testContext testrunner.TestContext, systemContext testrunner.SystemContext, resourceContext contexts.ResourceContext) {
// Do not run for tests with `SkipUpdate` explicitly set to 'true'.
if resourceContext.SkipUpdate {
return
}
// Do not run for tests without an update.yaml set.
if testContext.UpdateUnstruct == nil {
t.Logf("UpdateUnstruct not set; skipping testNoChangeAfterUpdate")
return
}
switch testContext.ResourceFixture.GVK.GroupKind() {
case schema.GroupKind{Group: "sql.cnrm.cloud.google.com", Kind: "SQLInstance"}: // test coverage for https://github.com/GoogleCloudPlatform/k8s-config-connector/issues/1802
default:
Expand Down

0 comments on commit af9b783

Please sign in to comment.