From 43f721eebdd9644c07e922f94b3b83ae4961cb0f Mon Sep 17 00:00:00 2001 From: yokishava Date: Tue, 22 Nov 2022 13:07:41 +0900 Subject: [PATCH] fix: change type of timestamp --- block_rich_text.go | 6 +++--- block_rich_text_test.go | 25 ++----------------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/block_rich_text.go b/block_rich_text.go index 281db213a..555a61989 100644 --- a/block_rich_text.go +++ b/block_rich_text.go @@ -327,17 +327,17 @@ func NewRichTextSectionUserGroupElement(usergroupID string) *RichTextSectionUser type RichTextSectionDateElement struct { Type RichTextSectionElementType `json:"type"` - Timestamp string `json:"timestamp"` + Timestamp JSONTime `json:"timestamp"` } func (r RichTextSectionDateElement) RichTextSectionElementType() RichTextSectionElementType { return r.Type } -func NewRichTextSectionDateElement(timestamp string) *RichTextSectionDateElement { +func NewRichTextSectionDateElement(timestamp int64) *RichTextSectionDateElement { return &RichTextSectionDateElement{ Type: RTSEDate, - Timestamp: timestamp, + Timestamp: JSONTime(timestamp), } } diff --git a/block_rich_text_test.go b/block_rich_text_test.go index 4c889eba5..5f97d58d1 100644 --- a/block_rich_text_test.go +++ b/block_rich_text_test.go @@ -7,28 +7,6 @@ import ( "github.com/go-test/deep" ) -const ( - dummyPayload = `{ - "type":"rich_text", - "block_id":"FaYCD", - "elements": [ - { - "type":"rich_text_section", - "elements": [ - { - "type":"channel", - "channel_id":"C012345678" - }, - { - "type":"text", - "text":"dummy_text" - } - ] - } - ] -}` -) - func TestRichTextBlock_UnmarshalJSON(t *testing.T) { cases := []struct { raw []byte @@ -80,12 +58,13 @@ func TestRichTextSection_UnmarshalJSON(t *testing.T) { err error }{ { - []byte(`{"elements":[{"type":"unknown","value":10},{"type":"text","text":"hi"}]}`), + []byte(`{"elements":[{"type":"unknown","value":10},{"type":"text","text":"hi"},{"type":"date","timestamp":1636961629}]}`), RichTextSection{ Type: RTESection, Elements: []RichTextSectionElement{ &RichTextSectionUnknownElement{Type: RTSEUnknown, Raw: `{"type":"unknown","value":10}`}, &RichTextSectionTextElement{Type: RTSEText, Text: "hi"}, + &RichTextSectionDateElement{Type: RTSEDate, Timestamp: JSONTime(1636961629)}, }, }, nil,