Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove redundant test
  • Loading branch information
gambtho committed Aug 31, 2023
commit 3f8bbe3abb3aa24b34719b9e27cfe01006c36a75
39 changes: 0 additions & 39 deletions pkg/controller/common/resource_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,42 +143,3 @@ func TestResourceReconciler_DeletionTimestamp(t *testing.T) {
errors.IsNotFound(c.Get(context.Background(), client.ObjectKeyFromObject(obj), actual)),
"expected not found error")
}

func TestResourceReconciler_Start(t *testing.T) {
deletionTimeStamp := metav1.NewTime(time.Now().Add(1 * time.Second))
obj := &corev1.Namespace{

TypeMeta: metav1.TypeMeta{
Kind: "Namespace",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "test",
DeletionTimestamp: &deletionTimeStamp,
Finalizers: []string{"finalizer"},
},
}

c := fake.NewClientBuilder().WithObjects(obj).Build()

rr := &resourceReconciler{
name: controllername.New("test", "name"),
client: c,
logger: logr.Discard(),
resources: []client.Object{obj},
}

obj.SetFinalizers([]string{})
require.NoError(t, c.Update(context.Background(), obj))

ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)
defer cancel()
// err in this case will be "context deadline exceeded"
_ = rr.Start(ctx)

// resource should be removed
actual := &corev1.Namespace{}
require.True(t,
errors.IsNotFound(c.Get(context.Background(), client.ObjectKeyFromObject(obj), actual)),
"expected not found error")
}