Skip to content

Commit

Permalink
Merge pull request #2281 from justinsb/dont_try_update_if_not_updateu…
Browse files Browse the repository at this point in the history
…nstruct

tests: skip update portions of the test if we don't have an update configured.
  • Loading branch information
google-oss-prow[bot] authored Jul 17, 2024
2 parents b16fc04 + 9431783 commit 9d22e19
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/controller/dynamic/dynamic_controller_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ func testUpdate(ctx context.Context, t *testing.T, testContext testrunner.TestCo
if resourceContext.SkipUpdate || resourceContext.IsAutoGenerated(systemContext.SMLoader) {
return
}
if testContext.UpdateUnstruct == nil {
t.Logf("UpdateUnstruct not set; skipping update")
return
}
kubeClient := systemContext.Manager.GetClient()
initialUnstruct := testContext.CreateUnstruct.DeepCopy()
if err := kubeClient.Get(ctx, testContext.NamespacedName, initialUnstruct); err != nil {
Expand All @@ -367,9 +371,6 @@ func testUpdate(ctx context.Context, t *testing.T, testContext testrunner.TestCo

// Update resource from test data
updateUnstruct := testContext.UpdateUnstruct.DeepCopy()
if updateUnstruct == nil {
t.Fatalf("updateUnstruct is nil for '%v'. should SkipUpdate be set to true in resourcefixture/contexts?", testContext.ResourceFixture.Name)
}
updateUnstruct.SetResourceVersion(initialUnstruct.GetResourceVersion())
// For resources with server-generated IDs, ensure the relevant fields are in the status
status := initialUnstruct.Object["status"]
Expand Down

0 comments on commit 9d22e19

Please sign in to comment.