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

Function TestCodec_Decode

internal/encoding/toml/codec_test.go:75–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

73}
74
75func TestCodec_Decode(t *testing.T) {
76 t.Run("OK", func(t *testing.T) {
77 codec := Codec{}
78
79 v := map[string]any{}
80
81 err := codec.Decode([]byte(original), v)
82 require.NoError(t, err)
83
84 assert.Equal(t, data, v)
85 })
86
87 t.Run("InvalidData", func(t *testing.T) {
88 codec := Codec{}
89
90 v := map[string]any{}
91
92 err := codec.Decode([]byte(`invalid data`), v)
93 require.Error(t, err)
94
95 t.Logf("decoding failed as expected: %s", err)
96 })
97}

Callers

nothing calls this directly

Calls 2

DecodeMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected