Skip to content

Commit

Permalink
Revert errorf->printf & rm some logging in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Brett Tofel <btofel@redhat.com>
  • Loading branch information
bentito committed May 30, 2024
1 parent 1c5192a commit eafc251
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 10 additions & 10 deletions internal/controllers/clusterextension_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestClusterExtensionNonExistentPackage(t *testing.T) {
t.Log("By running reconcile")
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: extKey})
require.Equal(t, ctrl.Result{}, res)
require.EqualError(t, err, fmt.Errorf("no package \"%v\" found", pkgName).Error())
require.EqualError(t, err, fmt.Sprintf("no package %q found", pkgName))

t.Log("By fetching updated cluster extension after reconcile")
require.NoError(t, cl.Get(ctx, extKey, clusterExtension))
Expand All @@ -78,7 +78,7 @@ func TestClusterExtensionNonExistentPackage(t *testing.T) {
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionFalse, cond.Status)
require.Equal(t, ocv1alpha1.ReasonResolutionFailed, cond.Reason)
require.Equal(t, fmt.Errorf("no package \"%v\" found", pkgName).Error(), cond.Message)
require.Equal(t, fmt.Sprintf("no package %q found", pkgName), cond.Message)

verifyInvariants(ctx, t, reconciler.Client, clusterExtension)
require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{}))
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestClusterExtensionNonExistentVersion(t *testing.T) {
t.Log("By running reconcile")
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: extKey})
require.Equal(t, ctrl.Result{}, res)
require.EqualError(t, err, fmt.Errorf("no package \"%v\" matching version \"%v\" found", pkgName, "0.50.0").Error())
require.EqualError(t, err, fmt.Sprintf(`no package %q matching version "0.50.0" found`, pkgName))

t.Log("By fetching updated cluster extension after reconcile")
require.NoError(t, cl.Get(ctx, extKey, clusterExtension))
Expand All @@ -120,7 +120,7 @@ func TestClusterExtensionNonExistentVersion(t *testing.T) {
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionFalse, cond.Status)
require.Equal(t, ocv1alpha1.ReasonResolutionFailed, cond.Reason)
require.Equal(t, fmt.Errorf("no package \"%v\" matching version \"%v\" found", pkgName, "0.50.0").Error(), cond.Message)
require.Equal(t, fmt.Sprintf(`no package %q matching version "0.50.0" found`, pkgName), cond.Message)
cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionFalse, cond.Status)
Expand Down Expand Up @@ -272,7 +272,7 @@ func TestClusterExtensionVersionNoChannel(t *testing.T) {
t.Log("By running reconcile")
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: extKey})
require.Equal(t, ctrl.Result{}, res)
require.EqualError(t, err, fmt.Errorf("no package \"%v\" matching version \"%v\" in channel \"%v\" found", pkgName, pkgVer, pkgChan).Error())
require.EqualError(t, err, fmt.Sprintf("no package %q matching version %q in channel %q found", pkgName, pkgVer, pkgChan))

t.Log("By fetching updated cluster extension after reconcile")
require.NoError(t, cl.Get(ctx, extKey, clusterExtension))
Expand All @@ -286,7 +286,7 @@ func TestClusterExtensionVersionNoChannel(t *testing.T) {
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionFalse, cond.Status)
require.Equal(t, ocv1alpha1.ReasonResolutionFailed, cond.Reason)
require.Equal(t, fmt.Errorf("no package \"%v\" matching version \"%v\" in channel \"%v\" found", pkgName, pkgVer, pkgChan).Error(), cond.Message)
require.Equal(t, fmt.Sprintf("no package %q matching version %q in channel %q found", pkgName, pkgVer, pkgChan), cond.Message)
cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)

require.NotNil(t, cond)
Expand Down Expand Up @@ -320,7 +320,7 @@ func TestClusterExtensionNoChannel(t *testing.T) {
t.Log("By running reconcile")
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: extKey})
require.Equal(t, ctrl.Result{}, res)
require.EqualError(t, err, fmt.Errorf("no package \"%v\" in channel \"%v\" found", pkgName, pkgChan).Error())
require.EqualError(t, err, fmt.Sprintf("no package %q in channel %q found", pkgName, pkgChan))

t.Log("By fetching updated cluster extension after reconcile")
require.NoError(t, cl.Get(ctx, extKey, clusterExtension))
Expand All @@ -334,7 +334,7 @@ func TestClusterExtensionNoChannel(t *testing.T) {
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionFalse, cond.Status)
require.Equal(t, ocv1alpha1.ReasonResolutionFailed, cond.Reason)
require.Equal(t, fmt.Errorf("no package \"%v\" in channel \"%v\" found", pkgName, pkgChan).Error(), cond.Message)
require.Equal(t, fmt.Sprintf("no package %q in channel %q found", pkgName, pkgChan), cond.Message)
cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionFalse, cond.Status)
Expand Down Expand Up @@ -369,7 +369,7 @@ func TestClusterExtensionNoVersion(t *testing.T) {
t.Log("By running reconcile")
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: extKey})
require.Equal(t, ctrl.Result{}, res)
require.EqualError(t, err, fmt.Errorf("no package \"%v\" matching version \"%v\" in channel \"%v\" found", pkgName, pkgVer, pkgChan).Error())
require.EqualError(t, err, fmt.Sprintf("no package %q matching version %q in channel %q found", pkgName, pkgVer, pkgChan))

t.Log("By fetching updated cluster extension after reconcile")
require.NoError(t, cl.Get(ctx, extKey, clusterExtension))
Expand All @@ -383,7 +383,7 @@ func TestClusterExtensionNoVersion(t *testing.T) {
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionFalse, cond.Status)
require.Equal(t, ocv1alpha1.ReasonResolutionFailed, cond.Reason)
require.Equal(t, fmt.Errorf("no package \"%v\" matching version \"%v\" in channel \"%v\" found", pkgName, pkgVer, pkgChan).Error(), cond.Message)
require.Equal(t, fmt.Sprintf("no package %q matching version %q in channel %q found", pkgName, pkgVer, pkgChan), cond.Message)
cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled)
require.NotNil(t, cond)
require.Equal(t, metav1.ConditionFalse, cond.Status)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ func TestClusterExtensionRegistryV1DisallowDependencies(t *testing.T) {
}()
fakeCatalogClient := testutil.NewFakeCatalogClient([]*catalogmetadata.Bundle{tt.bundle})
mockUnpacker := unpacker.(*MockUnpacker)
// Verify if mockUnpacker is correctly set
t.Log("MockUnpacker set to:", mockUnpacker)
// Set up the Unpack method to return a result with StatePending
mockUnpacker.On("Unpack", mock.Anything, mock.AnythingOfType("*v1alpha2.BundleDeployment")).Return(&source.Result{
State: source.StatePending,
Expand Down

0 comments on commit eafc251

Please sign in to comment.