forked from essentialkaos/slacker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
emoji_test.go
40 lines (35 loc) · 1020 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
40
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)
SLACK_API = "http://" + serverAddr + "/"
api := New("testing-token")
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)
}
}