From fa518ae480f775d881ec46b90a2fa241be8f6bdf Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 18 Oct 2023 11:05:36 -0700 Subject: [PATCH] Had msgpackhandle arg flipped; fix tests to work for Go < 1.19 --- util.go | 2 +- util_test.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/util.go b/util.go index 7ec8abf6..09c7742b 100644 --- a/util.go +++ b/util.go @@ -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) diff --git a/util_test.go b/util_test.go index 8ca0b657..9e3959fd 100644 --- a/util_test.go +++ b/util_test.go @@ -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) } @@ -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()) } }