From 74aaa4497f0187f937318875ce5047eca8fd0f5e Mon Sep 17 00:00:00 2001 From: Istvan Kispal Date: Fri, 23 Aug 2024 19:48:14 +0200 Subject: [PATCH] Adjust porchctl unit test for the slightly changed output --- pkg/cli/commands/rpkg/propose/command_test.go | 2 +- pkg/cli/commands/rpkg/proposedelete/command_test.go | 3 ++- pkg/cli/commands/rpkg/reject/command_test.go | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/cli/commands/rpkg/propose/command_test.go b/pkg/cli/commands/rpkg/propose/command_test.go index fce021f2..cce16abd 100644 --- a/pkg/cli/commands/rpkg/propose/command_test.go +++ b/pkg/cli/commands/rpkg/propose/command_test.go @@ -63,7 +63,7 @@ func TestCmd(t *testing.T) { lc: porchapi.PackageRevisionLifecycleDraft, }, "Cannot propose package": { - output: "cannot propose Published package\n", + output: pkgRevName + " failed (cannot propose Published package)\n", lc: porchapi.PackageRevisionLifecyclePublished, wantErr: true, }, diff --git a/pkg/cli/commands/rpkg/proposedelete/command_test.go b/pkg/cli/commands/rpkg/proposedelete/command_test.go index 7ad83ba2..2495170c 100644 --- a/pkg/cli/commands/rpkg/proposedelete/command_test.go +++ b/pkg/cli/commands/rpkg/proposedelete/command_test.go @@ -55,11 +55,12 @@ func TestCmd(t *testing.T) { ns string }{ "Package not found in ns": { + output: pkgRevName + " failed (packagerevisions.porch.kpt.dev \"" + pkgRevName + "\" not found)\n", ns: "doesnotexist", wantErr: true, }, "Package not published": { - output: "can only propose published packages for deletion; package " + pkgRevName + " is not published\n", + output: pkgRevName + " failed (can only propose published packages for deletion; package " + pkgRevName + " is not published)\n", ns: "ns", wantErr: true, }, diff --git a/pkg/cli/commands/rpkg/reject/command_test.go b/pkg/cli/commands/rpkg/reject/command_test.go index 94ca4730..e92601bb 100644 --- a/pkg/cli/commands/rpkg/reject/command_test.go +++ b/pkg/cli/commands/rpkg/reject/command_test.go @@ -58,6 +58,7 @@ func TestCmd(t *testing.T) { fakeclient client.WithWatch }{ "Package not found in ns": { + output: pkgRevName + " failed (packagerevisions.porch.kpt.dev \"" + pkgRevName + "\" not found)\n", wantErr: true, fakeclient: fake.NewClientBuilder().WithScheme(scheme). WithObjects(&porchapi.PackageRevision{ @@ -93,7 +94,7 @@ func TestCmd(t *testing.T) { }, "Reject draft package": { wantErr: true, - output: "cannot reject " + pkgRevName + " with lifecycle 'Draft'\n", + output: pkgRevName + " failed (cannot reject " + pkgRevName + " with lifecycle 'Draft')\n", fakeclient: fake.NewClientBuilder().WithScheme(scheme). WithObjects(&porchapi.PackageRevision{ TypeMeta: metav1.TypeMeta{ @@ -111,7 +112,7 @@ func TestCmd(t *testing.T) { }, "Reject published package": { wantErr: true, - output: "cannot reject " + pkgRevName + " with lifecycle 'Published'\n", + output: pkgRevName + " failed (cannot reject " + pkgRevName + " with lifecycle 'Published')\n", fakeclient: fake.NewClientBuilder().WithScheme(scheme). WithObjects(&porchapi.PackageRevision{ TypeMeta: metav1.TypeMeta{ @@ -128,7 +129,7 @@ func TestCmd(t *testing.T) { }}).Build(), }, "Reject proposed package": { - output: pkgRevName + " rejected\n", + output: pkgRevName + " no longer proposed for approval\n", fakeclient: fake.NewClientBuilder().WithInterceptorFuncs(interceptor.Funcs{ //fake subresourceupdate SubResourceUpdate: func(ctx context.Context, client client.Client, subResourceName string, obj client.Object, opts ...client.SubResourceUpdateOption) error {