(t *testing.T)
| 104 | } |
| 105 | |
| 106 | func 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 | } |