mirror of
https://github.com/spf13/viper
synced 2025-05-05 19:57:18 +00:00
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.
17 lines
396 B
Go
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"))
|
|
}
|