From fe62a7039fd1c5fb4e33f5c524744ae3616e97e8 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Fri, 11 May 2018 12:56:49 +0300 Subject: [PATCH] Fixed bug with decoding ExtensionPosition + Improved tests for custom unmarshalers --- api.go | 4 ++-- confluence_test.go | 14 ++++++++++++-- version.go | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/api.go b/api.go index 09259ce..2e86e31 100644 --- a/api.go +++ b/api.go @@ -626,8 +626,8 @@ func (c *ContainerID) UnmarshalJSON(b []byte) error { // UnmarshalJSON is custom position unmarshaler func (ep *ExtensionPosition) UnmarshalJSON(b []byte) error { - if string(b) == "none" { - *ep = -1 + if string(b) == "\"none\"" { + *ep = ExtensionPosition(-1) return nil } diff --git a/confluence_test.go b/confluence_test.go index 16f6416..9c28b5e 100644 --- a/confluence_test.go +++ b/confluence_test.go @@ -48,17 +48,27 @@ func (s *ConfluenceSuite) TestParamsEncoding(c *C) { } func (s *ConfluenceSuite) TestCustomUnmarshalers(c *C) { + var err error + d := &Date{} - d.UnmarshalJSON([]byte("\"2013-03-12T10:36:12.602+04:00\"")) + err = d.UnmarshalJSON([]byte("\"2013-03-12T10:36:12.602+04:00\"")) + c.Assert(err, IsNil) c.Assert(d.Year(), Equals, 2013) c.Assert(d.Month(), Equals, time.Month(3)) c.Assert(d.Day(), Equals, 12) t := &Timestamp{} - t.UnmarshalJSON([]byte("1523059214803")) + err = t.UnmarshalJSON([]byte("1523059214803")) + c.Assert(err, IsNil) c.Assert(t.Year(), Equals, 2018) c.Assert(t.Month(), Equals, time.Month(4)) c.Assert(t.Day(), Equals, 7) + + var e ExtensionPosition + err = e.UnmarshalJSON([]byte("\"none\"")) + + c.Assert(err, IsNil) + c.Assert(e, Equals, ExtensionPosition(-1)) } diff --git a/version.go b/version.go index c043acb..6eb3484 100644 --- a/version.go +++ b/version.go @@ -12,7 +12,7 @@ const ( NAME = "Go-Confluence" // VERSION is package version - VERSION = "1.5.0" + VERSION = "1.5.1" ) // ////////////////////////////////////////////////////////////////////////////////// //