mirror of
https://github.com/spf13/viper
synced 2025-05-11 22:57:21 +00:00
chore(linter): enable errorlint
This commit is contained in:
parent
0594522560
commit
0235f6179e
4 changed files with 12 additions and 6 deletions
|
@ -17,6 +17,7 @@ linters:
|
|||
- dogsled
|
||||
- dupl
|
||||
- durationcheck
|
||||
- errorlint
|
||||
- exhaustive
|
||||
- exportloopref
|
||||
- gci
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package encoding
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -34,7 +35,7 @@ func TestDecoderRegistry_RegisterDecoder(t *testing.T) {
|
|||
}
|
||||
|
||||
err = registry.RegisterDecoder("myformat", decoder{})
|
||||
if err != ErrDecoderFormatAlreadyRegistered {
|
||||
if !errors.Is(err, ErrDecoderFormatAlreadyRegistered) {
|
||||
t.Fatalf("expected ErrDecoderFormatAlreadyRegistered, got: %v", err)
|
||||
}
|
||||
})
|
||||
|
@ -70,7 +71,7 @@ func TestDecoderRegistry_Decode(t *testing.T) {
|
|||
var v string
|
||||
|
||||
err := registry.Decode("myformat", []byte("some value"), &v)
|
||||
if err != ErrDecoderNotFound {
|
||||
if !errors.Is(err, ErrDecoderNotFound) {
|
||||
t.Fatalf("expected ErrDecoderNotFound, got: %v", err)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package encoding
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -31,7 +32,7 @@ func TestEncoderRegistry_RegisterEncoder(t *testing.T) {
|
|||
}
|
||||
|
||||
err = registry.RegisterEncoder("myformat", encoder{})
|
||||
if err != ErrEncoderFormatAlreadyRegistered {
|
||||
if !errors.Is(err, ErrEncoderFormatAlreadyRegistered) {
|
||||
t.Fatalf("expected ErrEncoderFormatAlreadyRegistered, got: %v", err)
|
||||
}
|
||||
})
|
||||
|
@ -63,7 +64,7 @@ func TestEncoderRegistry_Decode(t *testing.T) {
|
|||
registry := NewEncoderRegistry()
|
||||
|
||||
_, err := registry.Encode("myformat", "some value")
|
||||
if err != ErrEncoderNotFound {
|
||||
if !errors.Is(err, ErrEncoderNotFound) {
|
||||
t.Fatalf("expected ErrEncoderNotFound, got: %v", err)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -8,6 +8,7 @@ package viper
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -1840,7 +1841,8 @@ func TestSafeWriteConfigWithExistingFile(t *testing.T) {
|
|||
v.SetConfigType("yaml")
|
||||
err := v.SafeWriteConfig()
|
||||
require.Error(t, err)
|
||||
_, ok := err.(ConfigFileAlreadyExistsError)
|
||||
var cfaeErr ConfigFileAlreadyExistsError
|
||||
ok := errors.As(err, &cfaeErr)
|
||||
assert.True(t, ok, "Expected ConfigFileAlreadyExistsError")
|
||||
}
|
||||
|
||||
|
@ -1865,7 +1867,8 @@ func TestSafeWriteConfigAsWithExistingFile(t *testing.T) {
|
|||
v.SetFs(fs)
|
||||
err := v.SafeWriteConfigAs("/test/c.yaml")
|
||||
require.Error(t, err)
|
||||
_, ok := err.(ConfigFileAlreadyExistsError)
|
||||
var cfaeErr ConfigFileAlreadyExistsError
|
||||
ok := errors.As(err, &cfaeErr)
|
||||
assert.True(t, ok, "Expected ConfigFileAlreadyExistsError")
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue