Skip to content

Commit

Permalink
add wait for confirming target deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
randmonkey committed Oct 8, 2024
1 parent 7c3b4e0 commit 7288234
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/envtest/konnect_entities_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/watch"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -126,6 +127,12 @@ func TestKongTarget(t *testing.T) {
t.Log("Deleting KongTarget")
require.NoError(t, clientNamespaced.Delete(ctx, createdTarget))

t.Log("Waiting for KongTarget to disappear")
assert.EventuallyWithT(t, func(c *assert.CollectT) {
err := clientNamespaced.Get(ctx, client.ObjectKeyFromObject(createdTarget), createdTarget)
assert.True(c, err != nil && k8serrors.IsNotFound(err))
}, waitTime, tickTime)

t.Log("Waiting for Target to be deleted in the SDK")
assert.EventuallyWithT(t, func(c *assert.CollectT) {
assert.True(c, factory.SDK.TargetsSDK.AssertExpectations(t))
Expand Down

0 comments on commit 7288234

Please sign in to comment.