Skip to content

Commit

Permalink
Fix #574 data sent as []byte should be decoded as []byte
Browse files Browse the repository at this point in the history
  • Loading branch information
amnonbc committed Jan 10, 2023
1 parent aed1a5b commit 016f324
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 0 additions & 1 deletion ably/internal/ablyutil/msgpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var handle codec.MsgpackHandle
func init() {
handle.Raw = true
handle.WriteExt = true
handle.RawToString = true
}

// UnmarshalMsgpack decodes the MessagePack-encoded data and stores the result in the
Expand Down
16 changes: 16 additions & 0 deletions ably/internal/ablyutil/msgpack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,25 @@ package ablyutil

import (
"bytes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

func TestUnmarshallByte(t *testing.T) {
buf := []byte{
0xc4, // bin8
2, // len
'a', 'a', // bytes
}
var target interface{}

err := UnmarshalMsgpack(buf, &target)
require.NoError(t, err)
assert.IsType(t, []byte{}, target,
"bin8 should be decoded as []byte, but instead we got %T", target)
}

func TestMsgpack(t *testing.T) {
type Object1 struct {
Key int64 `codec:"my_key"`
Expand Down

0 comments on commit 016f324

Please sign in to comment.