Skip to content

Commit

Permalink
Unit test updated to verify the user friendly error when the package …
Browse files Browse the repository at this point in the history
…doesn't exist
  • Loading branch information
rcmadhankumar committed Sep 19, 2023
1 parent f8cc005 commit 35f251a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/apiserver/registry/datapackaging/package_crd_rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)
}

}
Expand Down

0 comments on commit 35f251a

Please sign in to comment.