forked from slack-go/slack
-
Notifications
You must be signed in to change notification settings - Fork 4
/
emoji_test.go
39 lines (34 loc) · 1018 Bytes
/
emoji_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package slack
import (
"net/http"
"reflect"
"testing"
)
func getEmojiHandler(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response := []byte(`{"ok": true, "emoji": {
"bowtie": "https://my.slack.com/emoji/bowtie/46ec6f2bb0.png",
"squirrel": "https://my.slack.com/emoji/squirrel/f35f40c0e0.png",
"shipit": "alias:squirrel"
}}`)
rw.Write(response)
}
func TestGetEmoji(t *testing.T) {
http.HandleFunc("/emoji.list", getEmojiHandler)
once.Do(startServer)
api := New("testing-token", OptionAPIURL("http://"+serverAddr+"/"))
emojisResponse := map[string]string{
"bowtie": "https://my.slack.com/emoji/bowtie/46ec6f2bb0.png",
"squirrel": "https://my.slack.com/emoji/squirrel/f35f40c0e0.png",
"shipit": "alias:squirrel",
}
emojis, err := api.GetEmoji()
if err != nil {
t.Errorf("Unexpected error: %s", err)
return
}
eq := reflect.DeepEqual(emojis, emojisResponse)
if !eq {
t.Errorf("got %v; want %v", emojis, emojisResponse)
}
}