Skip to content

Commit

Permalink
Drop Ginkgo dependency and restructure tests
Browse files Browse the repository at this point in the history
Signed-off-by: Hidde Beydals <[email protected]>
  • Loading branch information
hiddeco committed Jun 15, 2021
1 parent 2b2cef8 commit cac5edb
Show file tree
Hide file tree
Showing 8 changed files with 400 additions and 389 deletions.
18 changes: 9 additions & 9 deletions controllers/bucket_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func TestBucketReconciler_Reconcile(t *testing.T) {
"secretkey": []byte("secret"),
},
}
g.Expect(newTestEnv.Create(ctx, secret)).To(Succeed())
defer newTestEnv.Delete(ctx, secret)
g.Expect(env.Create(ctx, secret)).To(Succeed())
defer env.Delete(ctx, secret)

obj := &sourcev1.Bucket{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -86,28 +86,28 @@ func TestBucketReconciler_Reconcile(t *testing.T) {
BucketName: s3Server.BucketName,
Endpoint: u.Host,
Insecure: true,
Interval: metav1.Duration{Duration: bucketInterval},
Timeout: &metav1.Duration{Duration: bucketTimeout},
Interval: metav1.Duration{Duration: interval},
Timeout: &metav1.Duration{Duration: timeout},
SecretRef: &meta.LocalObjectReference{
Name: secret.Name,
},
},
}
g.Expect(newTestEnv.Create(ctx, obj)).To(Succeed())
g.Expect(env.Create(ctx, obj)).To(Succeed())

key := client.ObjectKey{Name: obj.Name, Namespace: obj.Namespace}

// Wait for finalizer to be set
g.Eventually(func() bool {
if err := newTestEnv.Get(ctx, key, obj); err != nil {
if err := env.Get(ctx, key, obj); err != nil {
return false
}
return len(obj.Finalizers) > 0
}, timeout).Should(BeTrue())

// Wait for Bucket to be Ready
g.Eventually(func() bool {
if err := newTestEnv.Get(ctx, key, obj); err != nil {
if err := env.Get(ctx, key, obj); err != nil {
return false
}

Expand All @@ -124,11 +124,11 @@ func TestBucketReconciler_Reconcile(t *testing.T) {
obj.Generation == readyCondition.ObservedGeneration
}, timeout).Should(BeTrue())

g.Expect(newTestEnv.Delete(ctx, obj)).To(Succeed())
g.Expect(env.Delete(ctx, obj)).To(Succeed())

// Wait for Bucket to be deleted
g.Eventually(func() bool {
if err := newTestEnv.Get(ctx, key, obj); err != nil {
if err := env.Get(ctx, key, obj); err != nil {
return apierrors.IsNotFound(err)
}
return false
Expand Down
Loading

0 comments on commit cac5edb

Please sign in to comment.