-
Notifications
You must be signed in to change notification settings - Fork 5
/
flowdock_test.go
113 lines (105 loc) · 3.25 KB
/
flowdock_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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package main
import (
"testing"
)
func TestFlowsParse(t *testing.T) {
parseAvailableFlows()([]byte(mockedFlows))
if len(availableFlows) != 2 {
t.Errorf("parseAvailableFlows didn't parse payload, gave %+v", availableFlows)
}
}
func TestGetFlowUrl(t *testing.T) {
url, _ := getFlowURL("aaaaaaaa-d97b-0000-1111-555598671f8c")
if url != "https://api.flowdock.com/flows/fmpwizard/huston" {
t.Errorf("getFlowUrl gave %+v", url)
}
}
func TestGetFlowName(t *testing.T) {
name, _ := getFlowName("aaaaaaaa-d97b-0000-1111-555598671f8c")
if name != "huston" {
t.Errorf("getFlowName gave %+v", name)
}
}
func TestParseUsers(t *testing.T) {
parseUsers()([]byte(mockedUsers))
if len(currentUsers) != 2 {
t.Errorf("Didn't get two users, got: %+v", len(currentUsers))
}
}
func TestGetCortexUserID(t *testing.T) {
parseUsers()([]byte(mockedUsers))
userID := getCortexUserID("[email protected]")
if userID != 4877 {
t.Errorf("Didn't get the expected user ID, got %+v", userID)
}
}
const mockedFlows = (`[
{
"id": "aaaaaaaa-d97b-0000-1111-555598671f8c",
"name": "Huston",
"parameterized_name": "huston",
"email": "[email protected]",
"description": "Me",
"url": "https://api.flowdock.com/flows/fmpwizard/huston",
"web_url": "https://www.flowdock.com/app/fmpwizard/huston",
"access_mode": "organization",
"api_token": "123456789",
"open": true,
"joined": true,
"last_message_at": "2014-04-02T12:59:32.187Z",
"unread_mentions": 0,
"organization": {
"active": true,
"id": 30602,
"name": "FMPwizard",
"parameterized_name": "fmpwizard",
"url": "https://api.flowdock.com/organizations/fmpwizard",
"user_count": 2,
"user_limit": 0
}
},
{
"id": "9ad75588-d97b-0000-1111-555598671f8c",
"name": "Mission control",
"parameterized_name": "mission-control",
"email": "[email protected]",
"description": "Me",
"url": "https://api.flowdock.com/flows/fmpwizard/mission-control",
"web_url": "https://www.flowdock.com/app/fmpwizard/mission-control",
"access_mode": "organization",
"api_token": "123456789",
"open": true,
"joined": true,
"last_message_at": "2014-04-02T12:59:32.187Z",
"unread_mentions": 0,
"organization": {
"active": true,
"id": 30602,
"name": "FMPwizard",
"parameterized_name": "fmpwizard",
"url": "https://api.flowdock.com/organizations/fmpwizard",
"user_count": 2,
"user_limit": 0
}
}
]`)
const mockedUsers = (`
[
{
"id": 4877,
"nick": "cortex",
"email": "[email protected]",
"avatar": "https://d2cxspbh1aoie1.cloudfront.net/avatars/local/546440c99fa5e511111111111222222222222225/",
"name": "Cortex",
"website": null
},
{
"id": 31347,
"nick": "Diego",
"email": "[email protected]",
"avatar": "https://d2cxspbh1aoie1.cloudfront.net/avatars/5fcd8164c5ae83f10f060788840f258e/",
"name": "Diego Medina",
"website": ""
}
]
`)