lita-statuspage 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.rubocop.yml +7 -8
- data/.travis.yml +4 -4
- data/Gemfile +1 -1
- data/README.md +8 -5
- data/Rakefile +2 -2
- data/lib/lita/handlers/statuspage.rb +115 -185
- data/lita-statuspage.gemspec +9 -10
- data/locales/en.yml +44 -0
- data/spec/lita/handlers/statuspage_spec.rb +313 -325
- data/spec/spec_helper.rb +19 -0
- metadata +18 -30
data/lita-statuspage.gemspec
CHANGED
@@ -1,26 +1,25 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'lita-statuspage'
|
3
|
-
spec.version = '0.
|
3
|
+
spec.version = '0.3.0'
|
4
4
|
spec.authors = ['Eric Sigler']
|
5
5
|
spec.email = ['me@esigler.com']
|
6
|
-
spec.description =
|
7
|
-
spec.summary =
|
6
|
+
spec.description = 'A Statuspage.io plugin for Lita'
|
7
|
+
spec.summary = spec.description
|
8
8
|
spec.homepage = 'https://github.com/esigler/lita-statuspage'
|
9
9
|
spec.license = 'MIT'
|
10
10
|
spec.metadata = { 'lita_plugin_type' => 'handler' }
|
11
11
|
|
12
|
-
spec.files = `git ls-files`.split(
|
12
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
13
13
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
14
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
15
|
spec.require_paths = ['lib']
|
16
16
|
|
17
|
-
spec.add_runtime_dependency 'lita'
|
18
|
-
spec.add_runtime_dependency 'multi_json'
|
17
|
+
spec.add_runtime_dependency 'lita'
|
19
18
|
|
20
|
-
spec.add_development_dependency 'bundler'
|
21
|
-
spec.add_development_dependency 'rake'
|
22
|
-
spec.add_development_dependency 'rspec', '>= 3.0.0.beta2'
|
23
|
-
spec.add_development_dependency 'simplecov'
|
19
|
+
spec.add_development_dependency 'bundler'
|
24
20
|
spec.add_development_dependency 'coveralls'
|
21
|
+
spec.add_development_dependency 'rake'
|
22
|
+
spec.add_development_dependency 'rspec'
|
25
23
|
spec.add_development_dependency 'rubocop'
|
24
|
+
spec.add_development_dependency 'simplecov'
|
26
25
|
end
|
data/locales/en.yml
CHANGED
@@ -2,3 +2,47 @@ en:
|
|
2
2
|
lita:
|
3
3
|
handlers:
|
4
4
|
statuspage:
|
5
|
+
component:
|
6
|
+
updated: "Component %{id} updated"
|
7
|
+
not_found: Component not found
|
8
|
+
none: No components
|
9
|
+
invalid_status: Invalid status to use in updates
|
10
|
+
need_identifier: Need an identifier for the component
|
11
|
+
error:
|
12
|
+
invalid_arguments: "Error: invalid arguments"
|
13
|
+
api_request: Error making API request
|
14
|
+
help:
|
15
|
+
incident:
|
16
|
+
new:
|
17
|
+
syntax: sp incident new name:"<name>" status:<status> message:"<message>" twitter:<state> impact:<state>
|
18
|
+
desc: Create a new realtime incident'
|
19
|
+
update:
|
20
|
+
syntax: sp incident update id:ABC123 (...)
|
21
|
+
desc: Update an incident (takes same arguments as new)
|
22
|
+
list_all:
|
23
|
+
syntax: sp incident list all
|
24
|
+
desc: List all incidents
|
25
|
+
list_sch:
|
26
|
+
syntax: sp incident list scheduled
|
27
|
+
desc: List scheduled incidents
|
28
|
+
list_unr:
|
29
|
+
syntax: sp incident list unresolved
|
30
|
+
desc: List unresolved incidents
|
31
|
+
delete_l:
|
32
|
+
syntax: sp incident delete latest
|
33
|
+
desc: Delete latest incident
|
34
|
+
delete_i:
|
35
|
+
syntax: sp incident delete id:<id>
|
36
|
+
desc: Delete a specific incident
|
37
|
+
component:
|
38
|
+
list:
|
39
|
+
syntax: sp component list
|
40
|
+
desc: Lists all components
|
41
|
+
update:
|
42
|
+
syntax: sp component update
|
43
|
+
desc: Updates the component
|
44
|
+
incident:
|
45
|
+
created: "Incident %{id} created"
|
46
|
+
deleted: "Incident %{id} deleted"
|
47
|
+
updated: "Incident %{id} updated"
|
48
|
+
not_found: Incident not found
|
@@ -2,369 +2,357 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Lita::Handlers::Statuspage, lita_handler: true do
|
4
4
|
let(:incidents) do
|
5
|
-
|
5
|
+
double('Faraday::Response',
|
6
|
+
status: 200,
|
7
|
+
body: File.read('spec/files/incidents.json'))
|
6
8
|
end
|
7
9
|
|
8
10
|
let(:incidents_empty) do
|
9
|
-
'
|
11
|
+
double('Faraday::Response',
|
12
|
+
status: 200,
|
13
|
+
body: '[]')
|
10
14
|
end
|
11
15
|
|
12
16
|
let(:incidents_scheduled) do
|
13
|
-
|
17
|
+
double('Faraday::Response',
|
18
|
+
status: 200,
|
19
|
+
body: File.read('spec/files/incidents_scheduled.json'))
|
14
20
|
end
|
15
21
|
|
16
22
|
let(:incidents_unresolved) do
|
17
|
-
|
23
|
+
double('Faraday::Response',
|
24
|
+
status: 200,
|
25
|
+
body: File.read('spec/files/incidents_unresolved.json'))
|
18
26
|
end
|
19
27
|
|
20
28
|
let(:incidents_updated) do
|
21
|
-
|
29
|
+
double('Faraday::Response',
|
30
|
+
status: 200,
|
31
|
+
body: File.read('spec/files/incidents_update.json'))
|
22
32
|
end
|
23
33
|
|
24
34
|
let(:incident_new) do
|
25
|
-
|
35
|
+
double('Faraday::Response',
|
36
|
+
status: 201,
|
37
|
+
body: File.read('spec/files/incident_new.json'))
|
26
38
|
end
|
27
39
|
|
28
40
|
let(:incident_deleted) do
|
29
|
-
|
41
|
+
double('Faraday::Response',
|
42
|
+
status: 200,
|
43
|
+
body: File.read('spec/files/incident_deleted.json'))
|
30
44
|
end
|
31
45
|
|
32
46
|
let(:incident_updated) do
|
33
|
-
|
47
|
+
double('Faraday::Response',
|
48
|
+
status: 200,
|
49
|
+
body: File.read('spec/files/incident_updated.json'))
|
34
50
|
end
|
35
51
|
|
36
52
|
let(:components) do
|
37
|
-
|
53
|
+
double('Faraday::Response',
|
54
|
+
status: 200,
|
55
|
+
body: File.read('spec/files/components.json'))
|
38
56
|
end
|
39
57
|
|
40
58
|
let(:components_empty) do
|
41
|
-
'
|
59
|
+
double('Faraday::Response',
|
60
|
+
status: 200,
|
61
|
+
body: '[]')
|
42
62
|
end
|
43
63
|
|
44
64
|
let(:component_update) do
|
45
|
-
|
65
|
+
double('Faraday::Response',
|
66
|
+
status: 200,
|
67
|
+
body: File.read('spec/files/component_update.json'))
|
46
68
|
end
|
47
69
|
|
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
|
-
|
70
|
+
let(:generic_error) do
|
71
|
+
double('Faraday::Response',
|
72
|
+
status: 500,
|
73
|
+
body: '')
|
74
|
+
end
|
75
|
+
|
76
|
+
let(:generic_missing) do
|
77
|
+
double('Faraday::Response',
|
78
|
+
status: 404,
|
79
|
+
body: '')
|
80
|
+
end
|
81
|
+
|
82
|
+
def catch(symbol, result)
|
83
|
+
allow_any_instance_of(Faraday::Connection).to receive(symbol)
|
84
|
+
.and_return(result)
|
85
|
+
end
|
86
|
+
|
87
|
+
%w(statuspage sp).each do |name|
|
88
|
+
it do
|
89
|
+
is_expected.to route_command("#{name} incident new name:\"foo\"")
|
90
|
+
.to(:incident_new)
|
91
|
+
is_expected.to route_command("#{name} incident update latest")
|
92
|
+
.to(:incident_update)
|
93
|
+
is_expected.to route_command("#{name} incident list")
|
94
|
+
.to(:incident_list_all)
|
95
|
+
is_expected.to route_command("#{name} incident list all")
|
96
|
+
.to(:incident_list_all)
|
97
|
+
is_expected.to route_command("#{name} incident list scheduled")
|
98
|
+
.to(:incident_list_scheduled)
|
99
|
+
is_expected.to route_command("#{name} incident list unresolved")
|
100
|
+
.to(:incident_list_unresolved)
|
101
|
+
is_expected.to route_command("#{name} incident delete latest")
|
102
|
+
.to(:incident_delete_latest)
|
103
|
+
is_expected.to route_command("#{name} incident delete id:omgwtfbbq")
|
104
|
+
.to(:incident_delete)
|
105
|
+
is_expected.to route_command("#{name} component list")
|
106
|
+
.to(:component_list)
|
107
|
+
is_expected.to route_command("#{name} component list all")
|
108
|
+
.to(:component_list)
|
109
|
+
is_expected.to route_command("#{name} component update latest")
|
110
|
+
.to(:component_update)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
before do
|
115
|
+
Lita.config.handlers.statuspage.api_key = 'foo'
|
116
|
+
Lita.config.handlers.statuspage.page_id = 'bar'
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#incident_new' do
|
120
|
+
it 'shows an ack when the incident is created' do
|
121
|
+
catch(:post, incident_new)
|
122
|
+
send_command('statuspage incident new name:"lp0 on fire"')
|
123
|
+
expect(replies.last).to eq('Incident b0m7dz4tzpl3 created')
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'shows a warning if the incident does not have a required name' do
|
127
|
+
send_command('sp incident new status:investigating')
|
128
|
+
expect(replies.last).to eq('Error: invalid arguments')
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'shows a warning if the incident status is not valid' do
|
132
|
+
send_command('sp incident new name:"It dun broke" status:ignoring')
|
133
|
+
expect(replies.last).to eq('Error: invalid arguments')
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'shows a warning if the twitter status is not valid' do
|
137
|
+
send_command('sp incident new name:"It dun broke" twitter:lavender')
|
138
|
+
expect(replies.last).to eq('Error: invalid arguments')
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'shows a warning if the impact value is not valid' do
|
142
|
+
send_command('sp incident new name:"It dun broke" impact:apocalypse')
|
143
|
+
expect(replies.last).to eq('Error: invalid arguments')
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'shows an error if there was an issue creating the incident' do
|
147
|
+
catch(:get, generic_error)
|
148
|
+
send_command('statuspage incident new name:"It dun broke"')
|
149
|
+
expect(replies.last).to eq('Error making API request')
|
79
150
|
end
|
80
151
|
end
|
81
152
|
|
82
|
-
describe '
|
83
|
-
it '
|
84
|
-
|
153
|
+
describe '#incident_update' do
|
154
|
+
it 'shows an ack when the incident is updated' do
|
155
|
+
catch(:get, incidents_updated)
|
156
|
+
catch(:patch, incident_updated)
|
157
|
+
send_command('statuspage incident update id:b0m7dz4tzpl3 ' \
|
158
|
+
'message:"Howdy"')
|
159
|
+
expect(replies.last).to eq('Incident b0m7dz4tzpl3 updated')
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'shows a warning if the incident does not exist' do
|
163
|
+
catch(:get, incidents)
|
164
|
+
send_command('sp incident update id:b0m7dz4tzpl3 message:"Howdy"')
|
165
|
+
expect(replies.last).to eq('Incident not found')
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'shows a warning if the incident does not have an id' do
|
169
|
+
send_command('sp incident update status:investigating')
|
170
|
+
expect(replies.last).to eq('Error: invalid arguments')
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'shows a warning if the incident status is not valid' do
|
174
|
+
send_command('sp incident update id:b0m7dz4tzpl3 status:running_away')
|
175
|
+
expect(replies.last).to eq('Error: invalid arguments')
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'shows a warning if the twitter status is not valid' do
|
179
|
+
send_command('sp incident update id:b0m7dz4tzpl3 twitter:magenta')
|
180
|
+
expect(replies.last).to eq('Error: invalid arguments')
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'shows a warning if the impact value is not valid' do
|
184
|
+
send_command('sp incident update id:b0m7dz4tzpl3 impact:ragnarok')
|
185
|
+
expect(replies.last).to eq('Error: invalid arguments')
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'shows an error if there was an issue updating the incident' do
|
189
|
+
catch(:get, incidents_updated)
|
190
|
+
catch(:patch, generic_error)
|
191
|
+
send_command('sp incident update id:b0m7dz4tzpl3 message:"Howdy"')
|
192
|
+
expect(replies.last).to eq('Error making API request')
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe '#incident_list_all' do
|
197
|
+
it 'shows a list of incidents if there are any' do
|
198
|
+
catch(:get, incidents)
|
199
|
+
send_command('sp incident list all')
|
200
|
+
expect(replies.last).to eq('Test Incident (created: 2014-03-24, ' \
|
201
|
+
'status: resolved, id:td9ftgzcyz4m)')
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'shows a warning if there arent any' do
|
205
|
+
catch(:get, incidents_empty)
|
206
|
+
send_command('sp incident list all')
|
207
|
+
expect(replies.last).to eq('No incidents to list')
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'shows an error if there was an issue fetching the incidents' do
|
211
|
+
catch(:get, generic_error)
|
212
|
+
send_command('sp incident list all')
|
213
|
+
expect(replies.last).to eq('Error making API request')
|
85
214
|
end
|
86
215
|
end
|
87
216
|
|
88
|
-
describe '
|
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
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
describe '#incident_list_unresolved' do
|
231
|
-
it 'shows a list of incidents if there are any' do
|
232
|
-
response = double('Faraday::Response', status: 200, body: incidents_unresolved)
|
233
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(response)
|
234
|
-
send_command('statuspage incident list unresolved')
|
235
|
-
expect(replies.last).to eq('Unresolved incident (created: 2014-03-30, ' \
|
236
|
-
'status: investigating, id:2ttv50n0n8zj)')
|
237
|
-
end
|
238
|
-
|
239
|
-
it 'shows a warning if there arent any' do
|
240
|
-
response = double('Faraday::Response', status: 200, body: incidents_empty)
|
241
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(response)
|
242
|
-
send_command('statuspage incident list scheduled')
|
243
|
-
expect(replies.last).to eq('No incidents to list')
|
244
|
-
end
|
245
|
-
|
246
|
-
it 'shows an error if there was an issue fetching the incidents' do
|
247
|
-
response = double('Faraday::Response', status: 500, body: '')
|
248
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(response)
|
249
|
-
send_command('statuspage incident list scheduled')
|
250
|
-
expect(replies.last).to eq('Error fetching incidents')
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
describe '#incident_delete_latest' do
|
255
|
-
it 'shows an ack if the incident was deleted' do
|
256
|
-
get_response = double('Faraday::Response', status: 200, body: incidents_unresolved)
|
257
|
-
delete_response = double('Faraday::Response', status: 200, body: incident_deleted)
|
258
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(get_response)
|
259
|
-
allow_any_instance_of(Faraday::Connection).to receive(:delete).and_return(delete_response)
|
260
|
-
send_command('statuspage incident delete latest')
|
261
|
-
expect(replies.last).to eq('Incident 2ttv50n0n8zj deleted')
|
262
|
-
end
|
263
|
-
|
264
|
-
it 'shows a warning if there wasnt an incident to delete' do
|
265
|
-
response = double('Faraday::Response', status: 404, body: '')
|
266
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(response)
|
267
|
-
send_command('statuspage incident delete latest')
|
268
|
-
expect(replies.last).to eq('No latest incident found')
|
269
|
-
end
|
270
|
-
|
271
|
-
it 'shows an error if there was an issue deleting the incident' do
|
272
|
-
get_response = double('Faraday::Response', status: 200, body: incidents_unresolved)
|
273
|
-
delete_response = double('Faraday::Response', status: 500, body: '')
|
274
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(get_response)
|
275
|
-
allow_any_instance_of(Faraday::Connection).to receive(:delete).and_return(delete_response)
|
276
|
-
send_command('statuspage incident delete latest')
|
277
|
-
expect(replies.last).to eq('Error deleting incident')
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
describe '#incident_delete' do
|
282
|
-
it 'shows an ack if the incident was deleted' do
|
283
|
-
get_response = double('Faraday::Response', status: 200, body: incidents_unresolved)
|
284
|
-
delete_response = double('Faraday::Response', status: 200, body: incident_deleted)
|
285
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(get_response)
|
286
|
-
allow_any_instance_of(Faraday::Connection).to receive(:delete).and_return(delete_response)
|
287
|
-
send_command('statuspage incident delete id:2ttv50n0n8zj')
|
288
|
-
expect(replies.last).to eq('Incident 2ttv50n0n8zj deleted')
|
289
|
-
end
|
290
|
-
|
291
|
-
it 'shows a warning if there wasnt an incident to delete' do
|
292
|
-
response = double('Faraday::Response', status: 404, body: '')
|
293
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(response)
|
294
|
-
send_command('statuspage incident delete id:2ttv50n0n8zj')
|
295
|
-
expect(replies.last).to eq('Incident not found')
|
296
|
-
end
|
297
|
-
|
298
|
-
it 'shows an error if there was an issue deleting the incident' do
|
299
|
-
get_response = double('Faraday::Response', status: 200, body: incidents_unresolved)
|
300
|
-
delete_response = double('Faraday::Response', status: 500, body: '')
|
301
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(get_response)
|
302
|
-
allow_any_instance_of(Faraday::Connection).to receive(:delete).and_return(delete_response)
|
303
|
-
send_command('statuspage incident delete id:2ttv50n0n8zj')
|
304
|
-
expect(replies.last).to eq('Error deleting incident')
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
describe '#component_list' do
|
309
|
-
it 'shows a list of components if there are any' do
|
310
|
-
response = double('Faraday::Response', status: 200, body: components)
|
311
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(response)
|
312
|
-
send_command('statuspage component list')
|
313
|
-
expect(replies.last).to eq('Management Portal (example) (status: operational, id:v6z6tpldcw85)')
|
314
|
-
end
|
315
|
-
|
316
|
-
it 'shows a warning if there arent any' do
|
317
|
-
response = double('Faraday::Response', status: 200, body: components_empty)
|
318
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(response)
|
319
|
-
send_command('statuspage component list')
|
320
|
-
expect(replies.last).to eq('No components to list')
|
321
|
-
end
|
322
|
-
|
323
|
-
it 'shows an error if there was an issue fetching the components' do
|
324
|
-
response = double('Faraday::Response', status: 500, body: '')
|
325
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(response)
|
326
|
-
send_command('statuspage component list')
|
327
|
-
expect(replies.last).to eq('Error fetching components')
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
describe '#component_update' do
|
332
|
-
it 'shows an ack if the component is updated via id' do
|
333
|
-
get_response = double('Faraday::Response', status: 200, body: components)
|
334
|
-
patch_response = double('Faraday::Response', status: 200, body: component_update)
|
335
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(get_response)
|
336
|
-
allow_any_instance_of(Faraday::Connection).to receive(:patch).and_return(patch_response)
|
337
|
-
send_command('statuspage component update id:v6z6tpldcw85 status:major_outage')
|
338
|
-
expect(replies.last).to eq('Component v6z6tpldcw85 updated')
|
339
|
-
end
|
340
|
-
|
341
|
-
it 'shows an ack if the component is updated via name' do
|
342
|
-
get_response = double('Faraday::Response', status: 200, body: components)
|
343
|
-
patch_response = double('Faraday::Response', status: 200, body: component_update)
|
344
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(get_response)
|
345
|
-
allow_any_instance_of(Faraday::Connection).to receive(:patch).and_return(patch_response)
|
346
|
-
send_command('statuspage component update name:"Management Portal (example)" status:major_outage')
|
347
|
-
expect(replies.last).to eq('Component v6z6tpldcw85 updated')
|
348
|
-
end
|
349
|
-
|
350
|
-
it 'shows a warning if there is no identifier to the component' do
|
351
|
-
send_command('statuspage component update status:major_outage')
|
352
|
-
expect(replies.last).to eq('Need an identifier for the component')
|
353
|
-
end
|
354
|
-
|
355
|
-
it 'shows a warning if the status is invalid' do
|
356
|
-
send_command('statuspage component update id:v6z6tpldcw85 status:big_problem')
|
357
|
-
expect(replies.last).to eq('Invalid status to use in updates')
|
358
|
-
end
|
359
|
-
|
360
|
-
it 'shows an error if there was an issue updating the component' do
|
361
|
-
get_response = double('Faraday::Response', status: 200, body: components)
|
362
|
-
patch_response = double('Faraday::Response', status: 500, body: '')
|
363
|
-
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(get_response)
|
364
|
-
allow_any_instance_of(Faraday::Connection).to receive(:patch).and_return(patch_response)
|
365
|
-
send_command('statuspage component update id:v6z6tpldcw85 status:major_outage')
|
366
|
-
expect(replies.last).to eq('Error updating component')
|
367
|
-
end
|
217
|
+
describe '#incident_list_scheduled' do
|
218
|
+
it 'shows a list of incidents if there are any' do
|
219
|
+
catch(:get, incidents_scheduled)
|
220
|
+
send_command('sp incident list scheduled')
|
221
|
+
expect(replies.last).to eq('Test Maintenance (created: 2014-03-30, ' \
|
222
|
+
'status: scheduled, id:3tzsm37ryws0)')
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'shows a warning if there arent any' do
|
226
|
+
catch(:get, incidents_empty)
|
227
|
+
send_command('sp incident list scheduled')
|
228
|
+
expect(replies.last).to eq('No incidents to list')
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'shows an error if there was an issue fetching the incidents' do
|
232
|
+
catch(:get, generic_error)
|
233
|
+
send_command('sp incident list scheduled')
|
234
|
+
expect(replies.last).to eq('Error making API request')
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
describe '#incident_list_unresolved' do
|
239
|
+
it 'shows a list of incidents if there are any' do
|
240
|
+
catch(:get, incidents_unresolved)
|
241
|
+
send_command('statuspage incident list unresolved')
|
242
|
+
expect(replies.last).to eq('Unresolved incident (created: ' \
|
243
|
+
'2014-03-30, status: investigating, ' \
|
244
|
+
'id:2ttv50n0n8zj)')
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'shows a warning if there arent any' do
|
248
|
+
catch(:get, incidents_empty)
|
249
|
+
send_command('statuspage incident list scheduled')
|
250
|
+
expect(replies.last).to eq('No incidents to list')
|
251
|
+
end
|
252
|
+
|
253
|
+
it 'shows an error if there was an issue fetching the incidents' do
|
254
|
+
catch(:get, generic_error)
|
255
|
+
send_command('statuspage incident list scheduled')
|
256
|
+
expect(replies.last).to eq('Error making API request')
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
describe '#incident_delete_latest' do
|
261
|
+
it 'shows an ack if the incident was deleted' do
|
262
|
+
catch(:get, incidents_unresolved)
|
263
|
+
catch(:delete, incident_deleted)
|
264
|
+
send_command('statuspage incident delete latest')
|
265
|
+
expect(replies.last).to eq('Incident 2ttv50n0n8zj deleted')
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'shows a warning if there wasnt an incident to delete' do
|
269
|
+
catch(:get, generic_missing)
|
270
|
+
send_command('statuspage incident delete latest')
|
271
|
+
expect(replies.last).to eq('Incident not found')
|
272
|
+
end
|
273
|
+
|
274
|
+
it 'shows an error if there was an issue deleting the incident' do
|
275
|
+
catch(:get, incidents_unresolved)
|
276
|
+
catch(:delete, generic_error)
|
277
|
+
send_command('statuspage incident delete latest')
|
278
|
+
expect(replies.last).to eq('Error making API request')
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
describe '#incident_delete' do
|
283
|
+
it 'shows an ack if the incident was deleted' do
|
284
|
+
catch(:get, incidents_unresolved)
|
285
|
+
catch(:delete, incident_deleted)
|
286
|
+
send_command('statuspage incident delete id:2ttv50n0n8zj')
|
287
|
+
expect(replies.last).to eq('Incident 2ttv50n0n8zj deleted')
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'shows a warning if there wasnt an incident to delete' do
|
291
|
+
catch(:get, generic_missing)
|
292
|
+
send_command('statuspage incident delete id:2ttv50n0n8zj')
|
293
|
+
expect(replies.last).to eq('Incident not found')
|
294
|
+
end
|
295
|
+
|
296
|
+
it 'shows an error if there was an issue deleting the incident' do
|
297
|
+
catch(:get, incidents_unresolved)
|
298
|
+
catch(:delete, generic_error)
|
299
|
+
send_command('statuspage incident delete id:2ttv50n0n8zj')
|
300
|
+
expect(replies.last).to eq('Error making API request')
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
describe '#component_list' do
|
305
|
+
it 'shows a list of components if there are any' do
|
306
|
+
catch(:get, components)
|
307
|
+
send_command('statuspage component list')
|
308
|
+
expect(replies.last).to eq('Management Portal (example) ' \
|
309
|
+
'(status: operational, id:v6z6tpldcw85)')
|
310
|
+
end
|
311
|
+
|
312
|
+
it 'shows a warning if there arent any' do
|
313
|
+
catch(:get, components_empty)
|
314
|
+
send_command('statuspage component list')
|
315
|
+
expect(replies.last).to eq('No components')
|
316
|
+
end
|
317
|
+
|
318
|
+
it 'shows an error if there was an issue fetching the components' do
|
319
|
+
catch(:get, generic_error)
|
320
|
+
send_command('statuspage component list')
|
321
|
+
expect(replies.last).to eq('Error making API request')
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
describe '#component_update' do
|
326
|
+
it 'shows an ack if the component is updated via id' do
|
327
|
+
catch(:get, components)
|
328
|
+
catch(:patch, component_update)
|
329
|
+
send_command('sp component update id:v6z6tpldcw85 status:major_outage')
|
330
|
+
expect(replies.last).to eq('Component v6z6tpldcw85 updated')
|
331
|
+
end
|
332
|
+
|
333
|
+
it 'shows an ack if the component is updated via name' do
|
334
|
+
catch(:get, components)
|
335
|
+
catch(:patch, component_update)
|
336
|
+
send_command('sp component update name:"Management Portal ' \
|
337
|
+
'(example)" status:major_outage')
|
338
|
+
expect(replies.last).to eq('Component v6z6tpldcw85 updated')
|
339
|
+
end
|
340
|
+
|
341
|
+
it 'shows a warning if there is no identifier to the component' do
|
342
|
+
send_command('sp component update status:major_outage')
|
343
|
+
expect(replies.last).to eq('Need an identifier for the component')
|
344
|
+
end
|
345
|
+
|
346
|
+
it 'shows a warning if the status is invalid' do
|
347
|
+
send_command('sp component update id:v6z6tpldcw85 status:big_problem')
|
348
|
+
expect(replies.last).to eq('Invalid status to use in updates')
|
349
|
+
end
|
350
|
+
|
351
|
+
it 'shows an error if there was an issue updating the component' do
|
352
|
+
catch(:get, components)
|
353
|
+
catch(:patch, generic_error)
|
354
|
+
send_command('sp component update id:v6z6tpldcw85 status:major_outage')
|
355
|
+
expect(replies.last).to eq('Error making API request')
|
368
356
|
end
|
369
357
|
end
|
370
358
|
end
|