From 35f251a7d8c2e6b7af073605af41e169e10e4e91 Mon Sep 17 00:00:00 2001 From: rcmadhankumar Date: Tue, 19 Sep 2023 12:50:34 +0530 Subject: [PATCH] Unit test updated to verify the user friendly error when the package doesn't exist --- .../registry/datapackaging/package_crd_rest_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/apiserver/registry/datapackaging/package_crd_rest_test.go b/pkg/apiserver/registry/datapackaging/package_crd_rest_test.go index a1bdb167bc..3864213171 100644 --- a/pkg/apiserver/registry/datapackaging/package_crd_rest_test.go +++ b/pkg/apiserver/registry/datapackaging/package_crd_rest_test.go @@ -146,6 +146,7 @@ func TestPackageVersionGetPresentInOnlyNS(t *testing.T) { func TestPackageVersionGetNotFound(t *testing.T) { namespacedPackageVersion := excludedNonGlobalIntPackageVersion() name := namespacedPackageName + expectedError := "package.data.packaging.carvel.dev \"" + name + "\" not found" internalClient := fake.NewSimpleClientset(namespacedPackageVersion) fakeCoreClient := k8sfake.NewSimpleClientset(namespace()) @@ -157,8 +158,8 @@ func TestPackageVersionGetNotFound(t *testing.T) { t.Fatalf("Expected get operation to fail, but it didn't") } - if !errors.IsNotFound(err) { - t.Fatalf("Expected a not found error, got: %v", err) + if !errors.IsNotFound(err) || err.Error() != expectedError { + t.Fatalf("Expected error : %s, got: %v", expectedError, err) } }