(t *testing.T)
| 31 | } |
| 32 | |
| 33 | func 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 | } |