MCPcopy
hub / github.com/spf13/viper / TestCodec_Decode

Function TestCodec_Decode

internal/encoding/yaml/codec_test.go:106–128  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

104}
105
106func TestCodec_Decode(t *testing.T) {
107 t.Run("OK", func(t *testing.T) {
108 codec := Codec{}
109
110 v := map[string]any{}
111
112 err := codec.Decode([]byte(original), v)
113 require.NoError(t, err)
114
115 assert.Equal(t, decoded, v)
116 })
117
118 t.Run("InvalidData", func(t *testing.T) {
119 codec := Codec{}
120
121 v := map[string]any{}
122
123 err := codec.Decode([]byte(`invalid data`), v)
124 require.Error(t, err)
125
126 t.Logf("decoding failed as expected: %s", err)
127 })
128}

Callers

nothing calls this directly

Calls 2

DecodeMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected