spf13--viper/internal/encoding/error_test.go
Gerwin van de Steeg d6e5a55f3c
feat: add errors.Is support to all errors
Add functionality to support errors.Is on all generated errors to keep
in line with best practice on checking whether an error is of the
specified type as per changes to error handling in go1.13.
2024-01-09 17:50:25 +13:00

17 lines
396 B
Go

package encoding
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_encodingError(t *testing.T) {
err1 := fmt.Errorf("test error")
err2 := encodingError("encoding error")
assert.NotErrorIs(t, err1, err2)
assert.NotErrorIs(t, err2, err1)
assert.ErrorIs(t, err2, encodingError("encoding error"))
assert.NotErrorIs(t, err2, encodingError("other encodingerror"))
}