This commit is contained in:
andig 2023-05-29 17:37:46 +02:00
parent d4014cfce7
commit 701e7d9615

View file

@ -8,6 +8,7 @@ package viper
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"errors"
"io" "io"
"io/ioutil" //nolint:staticcheck "io/ioutil" //nolint:staticcheck
"os" "os"
@ -1484,6 +1485,21 @@ func TestWrongDirsSearchNotFoundForMerge(t *testing.T) {
assert.Equal(t, `default`, v.GetString(`key`)) assert.Equal(t, `default`, v.GetString(`key`))
} }
func TestUnwrap(t *testing.T) {
yamlInvalid := []byte(`hash: map
- foo
- bar
`)
SetConfigType("yaml")
err := ReadConfig(bytes.NewBuffer(yamlInvalid))
var cpe ConfigParseError
if !errors.As(err, &cpe) {
t.Fatalf("not a ConfigParseError")
}
}
func TestSub(t *testing.T) { func TestSub(t *testing.T) {
v := New() v := New()
v.SetConfigType("yaml") v.SetConfigType("yaml")