From 701e7d9615cf0ff340a72d76ad2e148c9d37830d Mon Sep 17 00:00:00 2001 From: andig Date: Mon, 29 May 2023 17:37:46 +0200 Subject: [PATCH] wip --- viper_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/viper_test.go b/viper_test.go index 926ffc2..45c71e1 100644 --- a/viper_test.go +++ b/viper_test.go @@ -8,6 +8,7 @@ package viper import ( "bytes" "encoding/json" + "errors" "io" "io/ioutil" //nolint:staticcheck "os" @@ -1484,6 +1485,21 @@ func TestWrongDirsSearchNotFoundForMerge(t *testing.T) { 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) { v := New() v.SetConfigType("yaml")