brightbox-cli 4.3.1 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/Gemfile.lock +5 -5
- data/brightbox-cli.gemspec +1 -1
- data/lib/brightbox-cli/commands/configmaps.rb +183 -0
- data/lib/brightbox-cli/commands/lbs/update.rb +1 -1
- data/lib/brightbox-cli/commands/servers/create.rb +0 -1
- data/lib/brightbox-cli/commands/servers/update.rb +1 -1
- data/lib/brightbox-cli/commands/volumes/attach.rb +1 -0
- data/lib/brightbox-cli/commands/volumes/update.rb +3 -4
- data/lib/brightbox-cli/config_map.rb +53 -0
- data/lib/brightbox-cli/version.rb +1 -1
- data/lib/brightbox_cli.rb +2 -0
- data/lib/gli_patches.rb +50 -0
- data/locales/en.yml +33 -0
- data/spec/commands/cloudips/update_spec.rb +144 -64
- data/spec/commands/configmaps/create_spec.rb +257 -0
- data/spec/commands/configmaps/destroy_spec.rb +156 -0
- data/spec/commands/configmaps/list_spec.rb +96 -0
- data/spec/commands/configmaps/show_spec.rb +236 -0
- data/spec/commands/configmaps/update_spec.rb +342 -0
- data/spec/commands/lbs/update_spec.rb +55 -1
- data/spec/commands/servers/create_spec.rb +10 -3
- data/spec/commands/servers/update_spec.rb +267 -12
- data/spec/commands/sql/instances/update_spec.rb +12 -10
- data/spec/commands/volumes/update_spec.rb +0 -1
- metadata +16 -3
@@ -1,82 +1,162 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "brightbox cloudips" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
let(:stderr) { output.stderr }
|
3
|
+
describe "brightbox cloudips update" do
|
4
|
+
let(:output) { FauxIO.new { Brightbox.run(argv) } }
|
5
|
+
let(:stdout) { output.stdout }
|
6
|
+
let(:stderr) { output.stderr }
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
before do
|
9
|
+
config_from_contents(API_CLIENT_CONFIG_CONTENTS)
|
10
|
+
|
11
|
+
stub_request(:post, "http://api.brightbox.localhost/token")
|
12
|
+
.to_return(
|
13
|
+
status: 200,
|
14
|
+
body: JSON.dump(
|
15
|
+
access_token: "ACCESS-TOKEN",
|
16
|
+
refresh_token: "REFRESH_TOKEN"
|
17
|
+
)
|
18
|
+
)
|
19
|
+
|
20
|
+
Brightbox.config.reauthenticate
|
21
|
+
end
|
22
|
+
|
23
|
+
context "" do
|
24
|
+
let(:argv) { %w[cloudips update] }
|
11
25
|
|
12
|
-
|
13
|
-
|
26
|
+
it "does not error" do
|
27
|
+
expect { output }.to_not raise_error
|
14
28
|
end
|
29
|
+
end
|
15
30
|
|
16
|
-
|
17
|
-
|
31
|
+
context "when name is updated" do
|
32
|
+
let(:argv) { ["cloudips", "update", "--name=#{new_name}", "cip-12345"] }
|
18
33
|
|
19
|
-
|
20
|
-
|
21
|
-
|
34
|
+
let(:json_response) do
|
35
|
+
<<-EOS
|
36
|
+
{
|
37
|
+
"id":"cip-12345",
|
38
|
+
"name":"#{new_name}"
|
39
|
+
}
|
40
|
+
EOS
|
22
41
|
end
|
23
42
|
|
24
|
-
context "
|
25
|
-
let(:
|
43
|
+
context "--name 'New name'" do
|
44
|
+
let(:new_name) { "New name" }
|
45
|
+
let(:expected_args) { ["cip-12345", { :name => new_name }] }
|
46
|
+
|
47
|
+
before do
|
48
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/cloud_ips/cip-12345?account_id=acc-12345")
|
49
|
+
.with(:headers => { "Content-Type" => "application/json" },
|
50
|
+
:body => {
|
51
|
+
name: "New name"
|
52
|
+
})
|
53
|
+
.and_return(:status => 200, :body => json_response)
|
26
54
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
"id":"cip-12345",
|
31
|
-
"name":"#{new_name}"
|
32
|
-
}
|
33
|
-
EOS
|
55
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/cloud_ips/cip-12345?account_id=acc-12345")
|
56
|
+
.with(:headers => { "Content-Type" => "application/json" })
|
57
|
+
.and_return(:status => 200, :body => json_response)
|
34
58
|
end
|
35
59
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
stub_request(:put, "http://api.brightbox.localhost/1.0/cloud_ips/cip-12345?account_id=acc-12345")
|
42
|
-
.with(:headers => { "Content-Type" => "application/json" },
|
43
|
-
:body => hash_including("name" => "New name"))
|
44
|
-
.and_return(:status => 200, :body => json_response)
|
45
|
-
|
46
|
-
stub_request(:get, "http://api.brightbox.localhost/1.0/cloud_ips/cip-12345?account_id=acc-12345")
|
47
|
-
.with(:headers => { "Content-Type" => "application/json" })
|
48
|
-
.and_return(:status => 200, :body => json_response)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "puts new name in update" do
|
52
|
-
expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
|
53
|
-
expect(stderr).to eq("")
|
54
|
-
expect(stdout).to include("cip-12345")
|
55
|
-
expect(stdout).to include("New name")
|
56
|
-
end
|
60
|
+
it "puts new name in update" do
|
61
|
+
expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
|
62
|
+
expect(stderr).to eq("")
|
63
|
+
expect(stdout).to include("cip-12345")
|
64
|
+
expect(stdout).to include("New name")
|
57
65
|
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "--name ''" do
|
69
|
+
let(:new_name) { "" }
|
70
|
+
let(:expected_args) { ["cip-12345", { :name => "" }] }
|
58
71
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
it "puts new name in update" do
|
75
|
-
expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
|
76
|
-
expect(stderr).to eq("")
|
77
|
-
expect(stdout).to include("cip-12345")
|
78
|
-
end
|
72
|
+
before do
|
73
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/cloud_ips/cip-12345?account_id=acc-12345")
|
74
|
+
.with(:headers => { "Content-Type" => "application/json" },
|
75
|
+
:body => hash_including("name" => ""))
|
76
|
+
.and_return(:status => 200, :body => json_response)
|
77
|
+
|
78
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/cloud_ips/cip-12345?account_id=acc-12345")
|
79
|
+
.with(:headers => { "Content-Type" => "application/json" })
|
80
|
+
.and_return(:status => 200, :body => json_response)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "puts new name in update" do
|
84
|
+
expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
|
85
|
+
expect(stderr).to eq("")
|
86
|
+
expect(stdout).to include("cip-12345")
|
79
87
|
end
|
80
88
|
end
|
81
89
|
end
|
90
|
+
|
91
|
+
context "--reverse-dns" do
|
92
|
+
let(:argv) { ["cloudips", "update", "--reverse-dns", "domain.example", "cip-dfsa3"] }
|
93
|
+
|
94
|
+
let(:json_response) do
|
95
|
+
<<-EOS
|
96
|
+
{
|
97
|
+
"id":"cip-dfsa3",
|
98
|
+
"reverse_dns":"domain.example"
|
99
|
+
}
|
100
|
+
EOS
|
101
|
+
end
|
102
|
+
|
103
|
+
before do
|
104
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/cloud_ips/cip-dfsa3?account_id=acc-12345")
|
105
|
+
.with(:headers => { "Content-Type" => "application/json" },
|
106
|
+
:body => {
|
107
|
+
reverse_dns: "domain.example"
|
108
|
+
})
|
109
|
+
.and_return(:status => 200, :body => json_response)
|
110
|
+
|
111
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/cloud_ips/cip-dfsa3?account_id=acc-12345")
|
112
|
+
.with(:headers => { "Content-Type" => "application/json" })
|
113
|
+
.and_return(:status => 200, :body => json_response)
|
114
|
+
end
|
115
|
+
|
116
|
+
it "puts new name in update" do
|
117
|
+
expect(stderr).to eq("")
|
118
|
+
expect(stdout).to include("cip-dfsa3")
|
119
|
+
expect(stdout).to include("domain.example")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "--delete-reverse-dns" do
|
124
|
+
let(:argv) { ["cloudips", "update", "--delete-reverse-dns", "cip-dfsa3"] }
|
125
|
+
|
126
|
+
let(:json_response) do
|
127
|
+
<<-EOS
|
128
|
+
{
|
129
|
+
"id":"cip-dfsa3",
|
130
|
+
"reverse_dns":""
|
131
|
+
}
|
132
|
+
EOS
|
133
|
+
end
|
134
|
+
|
135
|
+
before do
|
136
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/cloud_ips/cip-dfsa3?account_id=acc-12345")
|
137
|
+
.with(:headers => { "Content-Type" => "application/json" },
|
138
|
+
:body => {
|
139
|
+
reverse_dns: ""
|
140
|
+
})
|
141
|
+
.and_return(:status => 200, :body => json_response)
|
142
|
+
|
143
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/cloud_ips/cip-dfsa3?account_id=acc-12345")
|
144
|
+
.with(:headers => { "Content-Type" => "application/json" })
|
145
|
+
.and_return(:status => 200, :body => json_response)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "puts new name in update" do
|
149
|
+
expect(stderr).to eq("")
|
150
|
+
expect(stdout).to include("cip-dfsa3")
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context "--reverse-dns and --delete-reverse-dns options" do
|
155
|
+
let(:argv) { ["cloudips", "update", "--reverse-dns", "domain.example", "--delete-reverse-dns", "cip-dfsa3"] }
|
156
|
+
|
157
|
+
it "puts new name in update" do
|
158
|
+
expect(stderr).to eq("ERROR: You must either specify a reverse DNS record or --delete-reverse-dns\n")
|
159
|
+
expect(stdout).to eq("")
|
160
|
+
end
|
161
|
+
end
|
82
162
|
end
|
@@ -0,0 +1,257 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "brightbox configmaps create" do
|
4
|
+
let(:output) { FauxIO.new { Brightbox.run(argv) } }
|
5
|
+
let(:stdout) { output.stdout }
|
6
|
+
let(:stderr) { output.stderr }
|
7
|
+
|
8
|
+
let(:token) { SecureRandom.hex }
|
9
|
+
|
10
|
+
before do
|
11
|
+
config_from_contents(API_CLIENT_CONFIG_CONTENTS)
|
12
|
+
|
13
|
+
stub_request(:post, "http://api.brightbox.localhost/token")
|
14
|
+
.to_return(status: 200, body: JSON.dump(access_token: token))
|
15
|
+
|
16
|
+
Brightbox.config.reauthenticate
|
17
|
+
end
|
18
|
+
|
19
|
+
context "without options" do
|
20
|
+
let(:argv) { %w[configmaps create] }
|
21
|
+
|
22
|
+
it "does not error" do
|
23
|
+
expect { output }.to_not raise_error
|
24
|
+
|
25
|
+
expect(stderr).to match("Config map data is required as 'data' option")
|
26
|
+
|
27
|
+
expect(stdout).to eq("")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with 'name' and 'data'" do
|
32
|
+
let(:argv) { ["configmaps", "create", "--name", "tester", "--data", payload] }
|
33
|
+
let(:payload) { { key: "value" }.to_json }
|
34
|
+
|
35
|
+
before do
|
36
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/config_maps")
|
37
|
+
.with(headers: { "Content-Type" => "application/json" },
|
38
|
+
query: hash_including(account_id: "acc-12345"),
|
39
|
+
body: {
|
40
|
+
name: "tester",
|
41
|
+
data: {
|
42
|
+
key: "value"
|
43
|
+
}
|
44
|
+
})
|
45
|
+
.to_return(
|
46
|
+
status: 200,
|
47
|
+
body: {
|
48
|
+
id: "cfg-lk342",
|
49
|
+
name: "tester",
|
50
|
+
data: {
|
51
|
+
key: "value"
|
52
|
+
}
|
53
|
+
}.to_json
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "does not error" do
|
58
|
+
expect { output }.to_not raise_error
|
59
|
+
|
60
|
+
expect(stderr).not_to match("ERROR")
|
61
|
+
|
62
|
+
aggregate_failures do
|
63
|
+
expect(stdout).to match("id.*name")
|
64
|
+
|
65
|
+
expect(stdout).to match("cfg-lk342")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "with 'data'" do
|
71
|
+
let(:argv) { ["configmaps", "create", "--data", payload] }
|
72
|
+
let(:payload) { { key: "value" }.to_json }
|
73
|
+
|
74
|
+
before do
|
75
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/config_maps")
|
76
|
+
.with(headers: { "Content-Type" => "application/json" },
|
77
|
+
query: hash_including(account_id: "acc-12345"),
|
78
|
+
body: {
|
79
|
+
data: {
|
80
|
+
key: "value"
|
81
|
+
}
|
82
|
+
}.to_json)
|
83
|
+
.to_return(
|
84
|
+
status: 200,
|
85
|
+
body: {
|
86
|
+
id: "cfg-lk342",
|
87
|
+
data: {
|
88
|
+
key: "value"
|
89
|
+
}
|
90
|
+
}.to_json
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "does not error" do
|
95
|
+
expect { output }.to_not raise_error
|
96
|
+
|
97
|
+
expect(stderr).not_to match("ERROR")
|
98
|
+
|
99
|
+
aggregate_failures do
|
100
|
+
expect(stdout).to match("id.*name")
|
101
|
+
|
102
|
+
expect(stdout).to match("cfg-lk342")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "with invalid update" do
|
107
|
+
let(:payload) { "Not JSON!" }
|
108
|
+
|
109
|
+
it "does not error" do
|
110
|
+
expect { output }.to_not raise_error
|
111
|
+
|
112
|
+
expect(stderr).to eq("ERROR: Config map data was not valid JSON\n")
|
113
|
+
|
114
|
+
expect(stdout).to eq("")
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "with new map from 'data-file'" do
|
120
|
+
context "when filename is used" do
|
121
|
+
let(:argv) { ["configmaps", "create", "--data-file", data_file.path] }
|
122
|
+
let(:data_file) { Tempfile.open("config_map_test_data") }
|
123
|
+
|
124
|
+
around do |example|
|
125
|
+
data_file.write(payload)
|
126
|
+
data_file.close
|
127
|
+
|
128
|
+
example.run
|
129
|
+
|
130
|
+
data_file.unlink
|
131
|
+
end
|
132
|
+
|
133
|
+
context "with valid update" do
|
134
|
+
let(:payload) { { new_key: "new setting" }.to_json }
|
135
|
+
|
136
|
+
before do
|
137
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/config_maps")
|
138
|
+
.with(query: hash_including(account_id: "acc-12345"),
|
139
|
+
body: {
|
140
|
+
data: {
|
141
|
+
new_key: "new setting"
|
142
|
+
}
|
143
|
+
})
|
144
|
+
.to_return(
|
145
|
+
status: 200,
|
146
|
+
body: {
|
147
|
+
id: "cfg-s432l",
|
148
|
+
name: "",
|
149
|
+
data: {
|
150
|
+
new_key: "new setting"
|
151
|
+
}
|
152
|
+
}.to_json
|
153
|
+
)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "does not error" do
|
157
|
+
expect { output }.to_not raise_error
|
158
|
+
|
159
|
+
expect(stderr).to eq("Creating config map\n")
|
160
|
+
|
161
|
+
aggregate_failures do
|
162
|
+
expect(stdout).to match("cfg-s432l")
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context "with invalid update" do
|
167
|
+
let(:payload) { "Not JSON!" }
|
168
|
+
|
169
|
+
it "does not error" do
|
170
|
+
expect { output }.to_not raise_error
|
171
|
+
|
172
|
+
expect(stderr).to eq("ERROR: Config map data was not valid JSON\n")
|
173
|
+
|
174
|
+
expect(stdout).to eq("")
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
context "when '-' is used for STDIN" do
|
182
|
+
let(:argv) { ["configmaps", "create", "--data-file", "-", "cfg-stdin"] }
|
183
|
+
|
184
|
+
before do
|
185
|
+
stdin_data = StringIO.new
|
186
|
+
stdin_data.puts(payload)
|
187
|
+
stdin_data.rewind
|
188
|
+
|
189
|
+
$stdin = stdin_data
|
190
|
+
end
|
191
|
+
|
192
|
+
after do
|
193
|
+
$stdin = STDIN
|
194
|
+
end
|
195
|
+
|
196
|
+
context "with valid update" do
|
197
|
+
let(:payload) { { use_stdin: true }.to_json }
|
198
|
+
|
199
|
+
before do
|
200
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/config_maps")
|
201
|
+
.with(query: hash_including(account_id: "acc-12345"),
|
202
|
+
body: {
|
203
|
+
data: {
|
204
|
+
use_stdin: true
|
205
|
+
}
|
206
|
+
})
|
207
|
+
.to_return(
|
208
|
+
status: 200,
|
209
|
+
body: {
|
210
|
+
id: "cfg-mj53s",
|
211
|
+
name: "",
|
212
|
+
data: {
|
213
|
+
use_stdin: true
|
214
|
+
}
|
215
|
+
}.to_json
|
216
|
+
)
|
217
|
+
end
|
218
|
+
|
219
|
+
it "does not error" do
|
220
|
+
expect { output }.to_not raise_error
|
221
|
+
|
222
|
+
expect(stderr).to eq("Creating config map\n")
|
223
|
+
|
224
|
+
aggregate_failures do
|
225
|
+
expect(stdout).to match("cfg-mj53s")
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
context "with invalid update" do
|
230
|
+
let(:payload) { "Not JSON!" }
|
231
|
+
|
232
|
+
it "does not error" do
|
233
|
+
expect { output }.to_not raise_error
|
234
|
+
|
235
|
+
expect(stderr).to eq("ERROR: Config map data was not valid JSON\n")
|
236
|
+
|
237
|
+
expect(stdout).to eq("")
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
context "with mutually exclusive data options" do
|
244
|
+
let(:argv) { ["configmaps", "create", "--data", payload, "--data-file", "-"] }
|
245
|
+
let(:payload) { { new_key: "new value" }.to_json }
|
246
|
+
|
247
|
+
context "with invalid update" do
|
248
|
+
it "does not error" do
|
249
|
+
expect { output }.to_not raise_error
|
250
|
+
|
251
|
+
expect(stderr).to eq("ERROR: Config map data can only be passed by either 'data' or 'data-file'\n")
|
252
|
+
|
253
|
+
expect(stdout).to eq("")
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "brightbox configmaps destroy" do
|
4
|
+
let(:output) { FauxIO.new { Brightbox.run(argv) } }
|
5
|
+
let(:stdout) { output.stdout }
|
6
|
+
let(:stderr) { output.stderr }
|
7
|
+
|
8
|
+
before do
|
9
|
+
config_from_contents(API_CLIENT_CONFIG_CONTENTS)
|
10
|
+
|
11
|
+
stub_request(:post, "http://api.brightbox.localhost/token")
|
12
|
+
.to_return(
|
13
|
+
status: 200,
|
14
|
+
body: JSON.dump(
|
15
|
+
access_token: "ACCESS-TOKEN",
|
16
|
+
refresh_token: "REFRESH_TOKEN"
|
17
|
+
)
|
18
|
+
)
|
19
|
+
|
20
|
+
Brightbox.config.reauthenticate
|
21
|
+
end
|
22
|
+
|
23
|
+
context "without arguments" do
|
24
|
+
let(:argv) { %w[configmaps destroy] }
|
25
|
+
|
26
|
+
it "does not error" do
|
27
|
+
expect { output }.to_not raise_error
|
28
|
+
|
29
|
+
expect(stderr).to eq("ERROR: You must specify config map IDs as arguments\n")
|
30
|
+
|
31
|
+
expect(stdout).to match("")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with one argument" do
|
36
|
+
let(:argv) { %w[configmaps destroy cfg-xdwe2] }
|
37
|
+
|
38
|
+
before do
|
39
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/config_maps/cfg-xdwe2")
|
40
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
41
|
+
.to_return(
|
42
|
+
status: 200,
|
43
|
+
body: {
|
44
|
+
id: "cfg-xdwe2"
|
45
|
+
}.to_json
|
46
|
+
)
|
47
|
+
.to_return(
|
48
|
+
status: 200,
|
49
|
+
body: {
|
50
|
+
id: "cfg-xdwe2"
|
51
|
+
}.to_json
|
52
|
+
)
|
53
|
+
|
54
|
+
stub_request(:delete, "http://api.brightbox.localhost/1.0/config_maps/cfg-xdwe2")
|
55
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
56
|
+
.to_return(
|
57
|
+
status: 202,
|
58
|
+
body: {
|
59
|
+
id: "cfg-xdwe2"
|
60
|
+
}.to_json
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "does not error" do
|
65
|
+
expect { output }.to_not raise_error
|
66
|
+
|
67
|
+
expect(stderr).to match("Destroying cfg-xdwe2\n")
|
68
|
+
|
69
|
+
expect(stdout).to eq("")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "with multiple arguments" do
|
74
|
+
let(:argv) { %w[configmaps destroy cfg-12ds4 cfg-vf567] }
|
75
|
+
|
76
|
+
before do
|
77
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/config_maps/cfg-12ds4")
|
78
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
79
|
+
.to_return(
|
80
|
+
status: 200,
|
81
|
+
body: {
|
82
|
+
id: "cfg-12ds4"
|
83
|
+
}.to_json
|
84
|
+
)
|
85
|
+
.to_return(
|
86
|
+
status: 200,
|
87
|
+
body: {
|
88
|
+
id: "cfg-12ds4"
|
89
|
+
}.to_json
|
90
|
+
)
|
91
|
+
|
92
|
+
stub_request(:delete, "http://api.brightbox.localhost/1.0/config_maps/cfg-12ds4")
|
93
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
94
|
+
.to_return(
|
95
|
+
status: 200,
|
96
|
+
body: {
|
97
|
+
id: "cfg-12ds4"
|
98
|
+
}.to_json
|
99
|
+
)
|
100
|
+
|
101
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/config_maps/cfg-vf567")
|
102
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
103
|
+
.to_return(
|
104
|
+
status: 200,
|
105
|
+
body: {
|
106
|
+
id: "cfg-vf567"
|
107
|
+
}.to_json
|
108
|
+
)
|
109
|
+
.to_return(
|
110
|
+
status: 200,
|
111
|
+
body: {
|
112
|
+
id: "cfg-vf567"
|
113
|
+
}.to_json
|
114
|
+
)
|
115
|
+
|
116
|
+
stub_request(:delete, "http://api.brightbox.localhost/1.0/config_maps/cfg-vf567")
|
117
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
118
|
+
.to_return(
|
119
|
+
status: 200,
|
120
|
+
body: {
|
121
|
+
id: "cfg-vf567"
|
122
|
+
}.to_json
|
123
|
+
)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "does not error" do
|
127
|
+
expect { output }.to_not raise_error
|
128
|
+
|
129
|
+
expect(stderr).to match("Destroying cfg-12ds4\n")
|
130
|
+
expect(stderr).to match("Destroying cfg-vf567\n")
|
131
|
+
|
132
|
+
expect(stdout).to eq("")
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "with unknown argument" do
|
137
|
+
let(:argv) { %w[configmaps destroy cfg-lk234] }
|
138
|
+
|
139
|
+
before do
|
140
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/config_maps/cfg-lk234")
|
141
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
142
|
+
.to_return(
|
143
|
+
status: 404,
|
144
|
+
body: ""
|
145
|
+
)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "does not error" do
|
149
|
+
expect { output }.to_not raise_error
|
150
|
+
|
151
|
+
expect(stderr).to match("Couldn't find cfg-lk234\n")
|
152
|
+
|
153
|
+
expect(stdout).to eq("")
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|