Skip to content

Commit

Permalink
tests: skip update portions of the test if we don't have an update co…
Browse files Browse the repository at this point in the history
…nfigured.

This may enable us to stop requiring SkipUpdate in future.
  • Loading branch information
justinsb committed Jul 13, 2024
1 parent c3ba2c6 commit 9431783
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 9431783

Please sign in to comment.