forked from slack-go/slack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
81 lines (64 loc) · 2.02 KB
/
types.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package slacktest
import (
"log"
"net/http"
"net/http/httptest"
"sync"
"github.com/slack-go/slack"
)
type contextKey string
// ServerURLContextKey is the context key to store the server's url
const ServerURLContextKey contextKey = "__SERVER_URL__"
// ServerWSContextKey is the context key to store the server's ws url
const ServerWSContextKey contextKey = "__SERVER_WS_URL__"
// ServerBotNameContextKey is the bot name
const ServerBotNameContextKey contextKey = "__SERVER_BOTNAME__"
// ServerBotIDContextKey is the bot userid
const ServerBotIDContextKey contextKey = "__SERVER_BOTID__"
// ServerBotChannelsContextKey is the list of channels associated with the fake server
const ServerBotChannelsContextKey contextKey = "__SERVER_CHANNELS__"
// ServerBotGroupsContextKey is the list of channels associated with the fake server
const ServerBotGroupsContextKey contextKey = "__SERVER_GROUPS__"
// ServerBotHubNameContextKey is the context key for passing along the server name registered in the hub
const ServerBotHubNameContextKey contextKey = "__SERVER_HUBNAME__"
var masterHub = newHub()
type hub struct {
sync.RWMutex
serverChannels map[string]*messageChannels
}
type messageChannels struct {
seen chan (string)
sent chan (string)
posted chan (slack.Message)
}
type messageCollection struct {
sync.RWMutex
messages []string
}
type serverChannels struct {
sync.RWMutex
channels []slack.Channel
}
type serverGroups struct {
sync.RWMutex
channels []slack.Group
}
// Server represents a Slack Test server
type Server struct {
registered map[string]struct{}
server *httptest.Server
mux *http.ServeMux
Logger *log.Logger
BotName string
BotID string
ServerAddr string
SeenFeed chan (string)
channels *serverChannels
groups *serverGroups
seenInboundMessages *messageCollection
seenOutboundMessages *messageCollection
}
type fullInfoSlackResponse struct {
slack.Info
slack.SlackResponse
}