Skip to content

Commit

Permalink
Had msgpackhandle arg flipped; fix tests to work for Go < 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Swenson committed Oct 18, 2023
1 parent e837280 commit fa518ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func encodeMsgPack(in interface{}) (*bytes.Buffer, error) {
buf := bytes.NewBuffer(nil)
hd := codec.MsgpackHandle{
BasicHandle: codec.BasicHandle{
TimeNotBuiltin: false,
TimeNotBuiltin: true,
},
}
enc := codec.NewEncoder(buf, &hd)
Expand Down
5 changes: 3 additions & 2 deletions util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
// TestMsgpackEncodeTime ensures that we don't break backwards compatibility when updating go-msgpack with
// Raft binary formats.
func TestMsgpackEncodeTimeDefaultFormat(t *testing.T) {
tm, err := time.Parse(time.DateTime, time.DateTime)
stamp := "2006-01-02T15:04:05Z"
tm, err := time.Parse(time.RFC3339, stamp)
if err != nil {
t.Fatal(err)
}
Expand All @@ -22,7 +23,7 @@ func TestMsgpackEncodeTimeDefaultFormat(t *testing.T) {
expected := []byte{175, 1, 0, 0, 0, 14, 187, 75, 55, 229, 0, 0, 0, 0, 255, 255}

if !bytes.Equal(buf.Bytes(), expected) {
t.Errorf("Expected time %s to encode as %+v but got %+v", time.DateTime, expected, buf.Bytes())
t.Errorf("Expected time %s to encode as %+v but got %+v", stamp, expected, buf.Bytes())
}
}

Expand Down

0 comments on commit fa518ae

Please sign in to comment.