forked from slack-go/slack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapps_test.go
38 lines (32 loc) · 1013 Bytes
/
apps_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
package slack
import (
"encoding/json"
"net/http"
"testing"
)
func TestListEventAuthorizations(t *testing.T) {
http.HandleFunc("/apps.event.authorizations.list", testListEventAuthorizationsHandler)
once.Do(startServer)
api := New("", OptionAppLevelToken("test-token"), OptionAPIURL("http://"+serverAddr+"/"))
authorizations, err := api.ListEventAuthorizations("1-message-T012345678-DR12345678")
if err != nil {
t.Errorf("Failed, but should have succeeded")
} else if len(authorizations) != 1 {
t.Errorf("Didn't get 1 authorization")
} else if authorizations[0].UserID != "U123456789" {
t.Errorf("User ID is wrong")
}
}
func testListEventAuthorizationsHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
response, _ := json.Marshal(listEventAuthorizationsResponse{
SlackResponse: SlackResponse{Ok: true},
Authorizations: []EventAuthorization{
{
UserID: "U123456789",
TeamID: "T012345678",
},
},
})
w.Write(response)
}