Files
harness/blob/interface_test.go
Abhinav Singh 3e135cc128 feat: [CODE-4638]: increase code coverage (#4483) (#4485)
* 9d5d41 lint

* b58a69 lint

* 47a661 lint

* 5ebf79 lint

* 4ce1be Merge remote-tracking branch 'origin' into main-acm-cmxt

* 5db8d4 messagE

* fc54a0 coverage

* 5e6026 fix: [CODE-4585]: fix default reviewers with codeowner file error

* 10648b increase code coverage (#4483) (#4541)

* f74698 increase code coverage (#4483) (#4498)

* b1b395 increase code coverage (#4483) (#4487)

* 951ba4 increase code coverage (#4483)

* 8106d0 harness ACM created this fix
2025-10-21 18:45:38 +00:00

71 lines
1.9 KiB
Go

// Copyright 2023 Harness, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package blob
import (
"errors"
"testing"
)
func TestErrors(t *testing.T) {
tests := []struct {
name string
err error
expected string
}{
{
name: "ErrNotFound",
err: ErrNotFound,
expected: "resource not found",
},
{
name: "ErrNotSupported",
err: ErrNotSupported,
expected: "not supported",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if got := test.err.Error(); got != test.expected {
t.Errorf("expected error message %q, got %q", test.expected, got)
}
})
}
}
func TestErrorsAreDistinct(t *testing.T) {
if errors.Is(ErrNotFound, ErrNotSupported) {
t.Error("ErrNotFound should not be the same as ErrNotSupported")
}
if errors.Is(ErrNotSupported, ErrNotFound) {
t.Error("ErrNotSupported should not be the same as ErrNotFound")
}
}
func TestErrorsCanBeWrapped(t *testing.T) {
wrappedNotFound := errors.New("wrapped: " + ErrNotFound.Error())
wrappedNotSupported := errors.New("wrapped: " + ErrNotSupported.Error())
if wrappedNotFound.Error() != "wrapped: resource not found" {
t.Errorf("unexpected wrapped error message: %s", wrappedNotFound.Error())
}
if wrappedNotSupported.Error() != "wrapped: not supported" {
t.Errorf("unexpected wrapped error message: %s", wrappedNotSupported.Error())
}
}