Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kelseymills committed Nov 5, 2024
1 parent 01f17e8 commit 1e4725e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 28 deletions.
9 changes: 3 additions & 6 deletions block_rich_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
Expand Down
28 changes: 9 additions & 19 deletions bookmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,16 @@ 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 {
t.Errorf("Unexpected error: %s", err)
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)
}
Expand All @@ -112,24 +106,20 @@ 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 {
t.Errorf("Unexpected error: %s", err)
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)
}
Expand Down
2 changes: 0 additions & 2 deletions conversation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion slacktest/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1e4725e

Please sign in to comment.