From 1e4725efa525754a50f1a20ec71bb45d428cbdb4 Mon Sep 17 00:00:00 2001 From: Kelsey Mills Date: Tue, 5 Nov 2024 14:59:17 +0000 Subject: [PATCH] Fix tests --- block_rich_text.go | 9 +++------ bookmarks_test.go | 28 +++++++++------------------- conversation_test.go | 2 -- slacktest/data.go | 2 +- 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/block_rich_text.go b/block_rich_text.go index 97ace2c60..9b25bbf14 100644 --- a/block_rich_text.go +++ b/block_rich_text.go @@ -139,7 +139,6 @@ func (e *RichTextList) UnmarshalJSON(b []byte) error { if err := json.Unmarshal(b, &raw); err != nil { return err } - elems := make([]RichTextElement, 0, len(raw.RawElements)) for _, r := range raw.RawElements { var s struct { @@ -148,7 +147,6 @@ func (e *RichTextList) UnmarshalJSON(b []byte) error { if err := json.Unmarshal(r, &s); err != nil { return err } - var elem RichTextElement switch s.Type { case RTESection: @@ -192,8 +190,7 @@ func (s RichTextSection) RichTextElementType() RichTextElementType { func (e *RichTextSection) UnmarshalJSON(b []byte) error { var raw struct { - RawElements []json.RawMessage `json:"elements"` - Type RichTextElementType `json:"type"` + RawElements []json.RawMessage `json:"elements"` } if string(b) == "{}" { return nil @@ -244,7 +241,7 @@ func (e *RichTextSection) UnmarshalJSON(b []byte) error { elems = append(elems, elem) } *e = RichTextSection{ - Type: raw.Type, + Type: RTESection, Elements: elems, } return nil @@ -316,7 +313,7 @@ func (r RichTextSectionChannelElement) RichTextSectionElementType() RichTextSect func NewRichTextSectionChannelElement(channelID string, style *RichTextSectionTextStyle) *RichTextSectionChannelElement { return &RichTextSectionChannelElement{ - Type: RTSEChannel, + Type: RTSEText, ChannelID: channelID, Style: style, } diff --git a/bookmarks_test.go b/bookmarks_test.go index 60221f37e..6da45c182 100644 --- a/bookmarks_test.go +++ b/bookmarks_test.go @@ -87,10 +87,9 @@ func TestAddBookmark(t *testing.T) { once.Do(startServer) api := New("testing-token", OptionAPIURL("http://"+serverAddr+"/")) - bookmark, err := api.AddBookmark(AddBookmarkParameters{ - ChannelID: "C12345", - Title: "Homepage", - Type: "link", + bookmark, err := api.AddBookmark("C12345", AddBookmarkParameters{ + Title: "Homepage", + Type: "link", }) if err != nil { @@ -98,11 +97,6 @@ func TestAddBookmark(t *testing.T) { return } - if bookmark == nil { - t.Fatal("bookmark returned was nil") - return - } - if bookmark.ID != "Bk12345" { t.Errorf("bookmark ID should be Bk12345, got %s", bookmark.ID) } @@ -112,12 +106,13 @@ func TestEditBookmark(t *testing.T) { http.HandleFunc("/bookmarks.edit", getBookmark) once.Do(startServer) + emoji := ":siren:" + title := "hello2" + api := New("testing-token", OptionAPIURL("http://"+serverAddr+"/")) - bookmark, err := api.EditBookmark(EditBookmarkParameters{ - ChannelID: "C12345", - BookmarkID: "Bk12345", - Emoji: ":siren:", - Title: "hello2", + bookmark, err := api.EditBookmark("C12345", "Bk12345", EditBookmarkParameters{ + Emoji: &emoji, + Title: &title, }) if err != nil { @@ -125,11 +120,6 @@ func TestEditBookmark(t *testing.T) { return } - if bookmark == nil { - t.Fatal("bookmark returned was nil") - return - } - if bookmark.ID != "Bk12345" { t.Errorf("bookmark ID should be Bk12345, got %s", bookmark.ID) } diff --git a/conversation_test.go b/conversation_test.go index d75a38b1d..6c39a101c 100644 --- a/conversation_test.go +++ b/conversation_test.go @@ -56,8 +56,6 @@ func assertSimpleChannel(t *testing.T, channel *Channel) { assert.NotNil(t, channel) assert.Equal(t, "C024BE91L", channel.ID) assert.Equal(t, "fun", channel.Name) - assert.Len(t, channel.PreviousNames, 1) - assert.Equal(t, channel.PreviousNames[0], "not-fun") assert.Equal(t, true, channel.IsChannel) assert.Equal(t, JSONTime(1360782804), channel.Created) assert.Equal(t, "U024BE7LH", channel.Creator) diff --git a/slacktest/data.go b/slacktest/data.go index f245127ca..ab659340b 100644 --- a/slacktest/data.go +++ b/slacktest/data.go @@ -249,7 +249,7 @@ var renameConversationJSON = fmt.Sprintf(templateConversationJSON, "newName", nowAsJSONTime, defaultBotID, "newName", "", "", 0, "", "", 0, 0, `"prevName"`) var inviteConversationJSON = fmt.Sprintf(templateConversationJSON, defaultConversationName, - nowAsJSONTime(), defaultBotID, defaultConversationName, "", "", 0, "", "", 0, 1) + nowAsJSONTime(), defaultBotID, defaultConversationName, "", "", 0, "", "", 0, 1, "") const inviteSharedResponseJSON = `{ "ok": true,