Skip to content

Commit

Permalink
Consolidate client/reconciler initialization
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Short <tshort@redhat.com>
  • Loading branch information
tmshort committed Nov 16, 2023
1 parent bb80d16 commit bd389d8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 192 deletions.
31 changes: 10 additions & 21 deletions internal/controllers/admission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,8 @@ func TestOperatorSpecs(t *testing.T) {
d := od
t.Run(d.comment, func(t *testing.T) {
t.Parallel()
t.Logf("Running %s", d.comment)
cl, err := newClient()
require.NoError(t, err)
require.NotNil(t, cl)
err = cl.Create(ctx, d.spec)
cl := newClient(t)
err := cl.Create(ctx, d.spec)
require.Error(t, err)
require.ErrorContains(t, err, d.errMsg)
})
Expand Down Expand Up @@ -104,10 +101,8 @@ func TestOperatorInvalidSemver(t *testing.T) {
d := sm
t.Run(d, func(t *testing.T) {
t.Parallel()
cl, err := newClient()
require.NoError(t, err)
require.NotNil(t, cl)
err = cl.Create(ctx, operator(operatorsv1alpha1.OperatorSpec{
cl := newClient(t)
err := cl.Create(ctx, operator(operatorsv1alpha1.OperatorSpec{
PackageName: "package",
Version: d,
}))
Expand Down Expand Up @@ -161,14 +156,12 @@ func TestOperatorValidSemver(t *testing.T) {
d := smx
t.Run(d, func(t *testing.T) {
t.Parallel()
cl := newClient(t)
op := operator(operatorsv1alpha1.OperatorSpec{
PackageName: "package",
Version: d,
})
cl, err := newClient()
require.NoError(t, err)
require.NotNil(t, cl)
err = cl.Create(ctx, op)
err := cl.Create(ctx, op)
require.NoErrorf(t, err, "unexpected error for semver range %q: %w", d, err)
})
}
Expand All @@ -193,10 +186,8 @@ func TestOperatorInvalidChannel(t *testing.T) {
d := ch
t.Run(d, func(t *testing.T) {
t.Parallel()
cl, err := newClient()
require.NoError(t, err)
require.NotNil(t, cl)
err = cl.Create(ctx, operator(operatorsv1alpha1.OperatorSpec{
cl := newClient(t)
err := cl.Create(ctx, operator(operatorsv1alpha1.OperatorSpec{
PackageName: "package",
Channel: d,
}))
Expand All @@ -220,14 +211,12 @@ func TestOperatorValidChannel(t *testing.T) {
d := ch
t.Run(d, func(t *testing.T) {
t.Parallel()
cl := newClient(t)
op := operator(operatorsv1alpha1.OperatorSpec{
PackageName: "package",
Channel: d,
})
cl, err := newClient()
require.NoError(t, err)
require.NotNil(t, cl)
err = cl.Create(ctx, op)
err := cl.Create(ctx, op)
require.NoErrorf(t, err, "unexpected error creating valid channel %q: %w", d, err)
})
}
Expand Down
Loading

0 comments on commit bd389d8

Please sign in to comment.