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

Function TestCodec_Decode

internal/encoding/dotenv/codec_test.go:33–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31}
32
33func TestCodec_Decode(t *testing.T) {
34 t.Run("OK", func(t *testing.T) {
35 codec := Codec{}
36
37 v := map[string]any{}
38
39 err := codec.Decode([]byte(original), v)
40 require.NoError(t, err)
41
42 assert.Equal(t, data, v)
43 })
44
45 t.Run("InvalidData", func(t *testing.T) {
46 codec := Codec{}
47
48 v := map[string]any{}
49
50 err := codec.Decode([]byte(`invalid data`), v)
51 require.Error(t, err)
52
53 t.Logf("decoding failed as expected: %s", err)
54 })
55}

Callers

nothing calls this directly

Calls 2

DecodeMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected