brightbox-cli 4.2.1 → 4.3.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 +14 -2
- data/Gemfile.lock +5 -5
- data/brightbox-cli.gemspec +1 -1
- data/lib/brightbox-cli/commands/volumes/attach.rb +36 -0
- data/lib/brightbox-cli/commands/volumes/copy.rb +45 -0
- data/lib/brightbox-cli/commands/volumes/create.rb +63 -0
- data/lib/brightbox-cli/commands/volumes/destroy.rb +26 -0
- data/lib/brightbox-cli/commands/volumes/detach.rb +23 -0
- data/lib/brightbox-cli/commands/volumes/list.rb +16 -0
- data/lib/brightbox-cli/commands/volumes/locking.rb +39 -0
- data/lib/brightbox-cli/commands/volumes/resize.rb +36 -0
- data/lib/brightbox-cli/commands/volumes/show.rb +18 -0
- data/lib/brightbox-cli/commands/volumes/update.rb +50 -0
- data/lib/brightbox-cli/detailed_server.rb +13 -0
- data/lib/brightbox-cli/version.rb +1 -1
- data/lib/brightbox-cli/volume.rb +81 -0
- data/lib/brightbox_cli.rb +1 -0
- data/locales/en.yml +57 -1
- data/spec/commands/volumes/attach_spec.rb +165 -0
- data/spec/commands/volumes/copy_spec.rb +74 -0
- data/spec/commands/volumes/create_spec.rb +217 -0
- data/spec/commands/volumes/destroy_spec.rb +173 -0
- data/spec/commands/volumes/detach_spec.rb +180 -0
- data/spec/commands/volumes/list_spec.rb +99 -0
- data/spec/commands/volumes/resize_spec.rb +96 -0
- data/spec/commands/volumes/show_spec.rb +95 -0
- data/spec/commands/volumes/update_spec.rb +188 -0
- data/spec/support/volume_helpers.rb +167 -0
- metadata +35 -4
@@ -0,0 +1,180 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "brightbox volumes detach" do
|
4
|
+
include VolumeHelpers
|
5
|
+
|
6
|
+
let(:output) { FauxIO.new { Brightbox.run(argv) } }
|
7
|
+
let(:stdout) { output.stdout }
|
8
|
+
let(:stderr) { output.stderr }
|
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(
|
15
|
+
status: 200,
|
16
|
+
body: JSON.dump(
|
17
|
+
access_token: "ACCESS-TOKEN",
|
18
|
+
refresh_token: "REFRESH_TOKEN"
|
19
|
+
)
|
20
|
+
)
|
21
|
+
|
22
|
+
Brightbox.config.reauthenticate
|
23
|
+
end
|
24
|
+
|
25
|
+
context "without arguments" do
|
26
|
+
let(:argv) { %w[volumes detach] }
|
27
|
+
|
28
|
+
it "does not error" do
|
29
|
+
expect { output }.to_not raise_error
|
30
|
+
|
31
|
+
expect(stderr).to eq("ERROR: You must specify volume IDs as arguments\n")
|
32
|
+
|
33
|
+
expect(stdout).to match("")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with one argument" do
|
38
|
+
let(:argv) { %w[volumes detach vol-dkl43] }
|
39
|
+
|
40
|
+
before do
|
41
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/volumes/vol-dkl43")
|
42
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
43
|
+
.to_return(
|
44
|
+
status: 200,
|
45
|
+
body: volume_response(
|
46
|
+
id: "vol-dkl43",
|
47
|
+
status: "attached",
|
48
|
+
boot: false,
|
49
|
+
server: {
|
50
|
+
id: "srv-03431"
|
51
|
+
}
|
52
|
+
)
|
53
|
+
)
|
54
|
+
.to_return(
|
55
|
+
status: 200,
|
56
|
+
body: volume_response(
|
57
|
+
id: "vol-dkl43",
|
58
|
+
status: "detached",
|
59
|
+
boot: false,
|
60
|
+
server: nil
|
61
|
+
)
|
62
|
+
)
|
63
|
+
|
64
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/volumes/vol-dkl43/detach")
|
65
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
66
|
+
.to_return(
|
67
|
+
status: 202,
|
68
|
+
body: volume_response(
|
69
|
+
id: "vol-dkl43",
|
70
|
+
status: "detached",
|
71
|
+
server: {
|
72
|
+
id: "srv-03431"
|
73
|
+
}
|
74
|
+
)
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "does not error" do
|
79
|
+
expect { output }.to_not raise_error
|
80
|
+
|
81
|
+
expect(stderr).to match("Detaching vol-dkl43\n")
|
82
|
+
|
83
|
+
aggregate_failures do
|
84
|
+
expect(stdout).to match("vol-dkl43")
|
85
|
+
expect(stdout).to match("detached")
|
86
|
+
expect(stdout).to match("false")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "with multiple arguments" do
|
92
|
+
let(:argv) { %w[volumes detach vol-p3241 vol-3422f] }
|
93
|
+
|
94
|
+
before do
|
95
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/volumes/vol-p3241")
|
96
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
97
|
+
.to_return(
|
98
|
+
status: 200,
|
99
|
+
body: volume_response(
|
100
|
+
id: "vol-p3241",
|
101
|
+
status: "attached",
|
102
|
+
boot: false,
|
103
|
+
server: {
|
104
|
+
id: "srv-03431"
|
105
|
+
}
|
106
|
+
)
|
107
|
+
)
|
108
|
+
.to_return(
|
109
|
+
status: 200,
|
110
|
+
body: volume_response(
|
111
|
+
id: "vol-p3241",
|
112
|
+
status: "detached",
|
113
|
+
boot: false,
|
114
|
+
server: nil
|
115
|
+
)
|
116
|
+
)
|
117
|
+
|
118
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/volumes/vol-p3241/detach")
|
119
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
120
|
+
.to_return(
|
121
|
+
status: 202,
|
122
|
+
body: volume_response(
|
123
|
+
id: "vol-p3241",
|
124
|
+
status: "detached",
|
125
|
+
server: {
|
126
|
+
id: "srv-03431"
|
127
|
+
}
|
128
|
+
)
|
129
|
+
)
|
130
|
+
|
131
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/volumes/vol-3422f")
|
132
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
133
|
+
.to_return(
|
134
|
+
status: 200,
|
135
|
+
body: volume_response(
|
136
|
+
id: "vol-3422f",
|
137
|
+
status: "attached",
|
138
|
+
boot: false,
|
139
|
+
server: {
|
140
|
+
id: "srv-03431"
|
141
|
+
}
|
142
|
+
)
|
143
|
+
)
|
144
|
+
.to_return(
|
145
|
+
status: 200,
|
146
|
+
body: volume_response(
|
147
|
+
id: "vol-3422f",
|
148
|
+
status: "detached",
|
149
|
+
boot: false,
|
150
|
+
server: nil
|
151
|
+
)
|
152
|
+
)
|
153
|
+
|
154
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/volumes/vol-3422f/detach")
|
155
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
156
|
+
.to_return(
|
157
|
+
status: 202,
|
158
|
+
body: volume_response(
|
159
|
+
id: "vol-3422f",
|
160
|
+
status: "detached",
|
161
|
+
server: {
|
162
|
+
id: "srv-03431"
|
163
|
+
}
|
164
|
+
)
|
165
|
+
)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "does not error" do
|
169
|
+
expect { output }.to_not raise_error
|
170
|
+
|
171
|
+
expect(stderr).to match("Detaching vol-3422f\n")
|
172
|
+
|
173
|
+
aggregate_failures do
|
174
|
+
expect(stdout).to match("vol-p3241")
|
175
|
+
expect(stdout).to match("detached")
|
176
|
+
expect(stdout).to match("false")
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "brightbox volumes list" do
|
4
|
+
include VolumeHelpers
|
5
|
+
|
6
|
+
let(:output) { FauxIO.new { Brightbox.run(argv) } }
|
7
|
+
let(:stdout) { output.stdout }
|
8
|
+
let(:stderr) { output.stderr }
|
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(
|
15
|
+
status: 200,
|
16
|
+
body: JSON.dump(
|
17
|
+
access_token: "ACCESS-TOKEN",
|
18
|
+
refresh_token: "REFRESH_TOKEN"
|
19
|
+
)
|
20
|
+
)
|
21
|
+
|
22
|
+
Brightbox.config.reauthenticate
|
23
|
+
end
|
24
|
+
|
25
|
+
context "without arguments" do
|
26
|
+
let(:argv) { %w[volumes list] }
|
27
|
+
|
28
|
+
before do
|
29
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/volumes")
|
30
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
31
|
+
.to_return(
|
32
|
+
status: 200,
|
33
|
+
body: volumes_response
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "does not error" do
|
38
|
+
expect { output }.to_not raise_error
|
39
|
+
|
40
|
+
expect(stderr).to eq("")
|
41
|
+
|
42
|
+
aggregate_failures do
|
43
|
+
expect(stdout).to match("id.*type.*size.*status.*server.*boot")
|
44
|
+
|
45
|
+
expect(stdout).to match("vol-12345")
|
46
|
+
expect(stdout).to match("network")
|
47
|
+
expect(stdout).to match("10240")
|
48
|
+
expect(stdout).to match("attached")
|
49
|
+
expect(stdout).to match("srv-12345")
|
50
|
+
expect(stdout).to match("false")
|
51
|
+
|
52
|
+
expect(stdout).to match("vol-abcde")
|
53
|
+
expect(stdout).to match("network")
|
54
|
+
expect(stdout).to match("10240")
|
55
|
+
expect(stdout).to match("attached")
|
56
|
+
expect(stdout).to match("srv-12345")
|
57
|
+
expect(stdout).to match("true")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "with identifier" do
|
63
|
+
let(:argv) { %w[volumes list vol-12345] }
|
64
|
+
|
65
|
+
before do
|
66
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/volumes/vol-12345")
|
67
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
68
|
+
.to_return(
|
69
|
+
status: 200,
|
70
|
+
body: volume_response(
|
71
|
+
id: "vol-12345",
|
72
|
+
storage_type: "network",
|
73
|
+
size: 10_240,
|
74
|
+
status: "attached",
|
75
|
+
server: {
|
76
|
+
id: "srv-12345"
|
77
|
+
}
|
78
|
+
)
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "does not error" do
|
83
|
+
expect { output }.to_not raise_error
|
84
|
+
|
85
|
+
expect(stderr).not_to match("ERROR")
|
86
|
+
|
87
|
+
aggregate_failures do
|
88
|
+
expect(stdout).to match("id.*type.*size.*status.*server.*boot")
|
89
|
+
|
90
|
+
expect(stdout).to match("vol-12345")
|
91
|
+
expect(stdout).to match("network")
|
92
|
+
expect(stdout).to match("10240")
|
93
|
+
expect(stdout).to match("attached")
|
94
|
+
expect(stdout).to match("srv-12345")
|
95
|
+
expect(stdout).to match("false")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "brightbox volumes resize" do
|
4
|
+
include VolumeHelpers
|
5
|
+
|
6
|
+
let(:output) { FauxIO.new { Brightbox.run(argv) } }
|
7
|
+
let(:stdout) { output.stdout }
|
8
|
+
let(:stderr) { output.stderr }
|
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(
|
15
|
+
status: 200,
|
16
|
+
body: JSON.dump(
|
17
|
+
access_token: "ACCESS-TOKEN",
|
18
|
+
refresh_token: "REFRESH_TOKEN"
|
19
|
+
)
|
20
|
+
)
|
21
|
+
|
22
|
+
Brightbox.config.reauthenticate
|
23
|
+
end
|
24
|
+
|
25
|
+
context "without arguments" do
|
26
|
+
let(:argv) { %w[volumes resize] }
|
27
|
+
|
28
|
+
it "does not error" do
|
29
|
+
expect { output }.to_not raise_error
|
30
|
+
|
31
|
+
expect(stderr).to eq("ERROR: You must specify the volume ID as the first argument\n")
|
32
|
+
|
33
|
+
expect(stdout).to match("")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "without size option" do
|
38
|
+
let(:argv) { %w[volumes resize vol-i89u9] }
|
39
|
+
|
40
|
+
it "does not error" do
|
41
|
+
expect { output }.to_not raise_error
|
42
|
+
|
43
|
+
expect(stderr).to eq("ERROR: A 'size' option is required\n")
|
44
|
+
|
45
|
+
expect(stdout).to match("")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with size option" do
|
50
|
+
let(:argv) { %w[volumes resize --size 20480 vol-op324] }
|
51
|
+
|
52
|
+
before do
|
53
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/volumes/vol-op324")
|
54
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
55
|
+
.to_return(
|
56
|
+
status: 200,
|
57
|
+
body: volume_response(
|
58
|
+
id: "vol-op324",
|
59
|
+
size: 10_240
|
60
|
+
)
|
61
|
+
)
|
62
|
+
.to_return(
|
63
|
+
status: 200,
|
64
|
+
body: volume_response(
|
65
|
+
id: "vol-op324",
|
66
|
+
size: 20_480
|
67
|
+
)
|
68
|
+
)
|
69
|
+
|
70
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/volumes/vol-op324/resize")
|
71
|
+
.with(query: hash_including(account_id: "acc-12345"),
|
72
|
+
body: hash_including(
|
73
|
+
from: 10_240,
|
74
|
+
to: 20_480
|
75
|
+
))
|
76
|
+
.to_return(
|
77
|
+
status: 202,
|
78
|
+
body: volume_response(
|
79
|
+
id: "vol-op324",
|
80
|
+
size: 20_480
|
81
|
+
)
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "does not error" do
|
86
|
+
expect { output }.to_not raise_error
|
87
|
+
|
88
|
+
expect(stderr).to eq("Resizing vol-op324\n")
|
89
|
+
|
90
|
+
aggregate_failures do
|
91
|
+
expect(stdout).to match("vol-op324")
|
92
|
+
expect(stdout).to match("20480")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "brightbox volumes show" do
|
4
|
+
include VolumeHelpers
|
5
|
+
|
6
|
+
let(:output) { FauxIO.new { Brightbox.run(argv) } }
|
7
|
+
let(:stdout) { output.stdout }
|
8
|
+
let(:stderr) { output.stderr }
|
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(
|
15
|
+
status: 200,
|
16
|
+
body: JSON.dump(
|
17
|
+
access_token: "ACCESS-TOKEN",
|
18
|
+
refresh_token: "REFRESH_TOKEN"
|
19
|
+
)
|
20
|
+
)
|
21
|
+
|
22
|
+
Brightbox.config.reauthenticate
|
23
|
+
end
|
24
|
+
|
25
|
+
context "without arguments" do
|
26
|
+
let(:argv) { %w[volumes show] }
|
27
|
+
|
28
|
+
before do
|
29
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/volumes")
|
30
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
31
|
+
.to_return(
|
32
|
+
status: 200,
|
33
|
+
body: volumes_response
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "does not error" do
|
38
|
+
expect { output }.to_not raise_error
|
39
|
+
|
40
|
+
expect(stderr).to eq("")
|
41
|
+
|
42
|
+
aggregate_failures do
|
43
|
+
expect(stdout).to match("id: vol-12345")
|
44
|
+
expect(stdout).to match("id: vol-abcde")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with identifier" do
|
50
|
+
let(:argv) { %w[volumes show vol-88878] }
|
51
|
+
|
52
|
+
before do
|
53
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/volumes/vol-88878")
|
54
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
55
|
+
.to_return(
|
56
|
+
status: 200,
|
57
|
+
body: volume_response(
|
58
|
+
id: "vol-88878",
|
59
|
+
description: "A volume for testing",
|
60
|
+
filesystem_type: "ext4",
|
61
|
+
storage_type: "network",
|
62
|
+
size: 10_240,
|
63
|
+
status: "attached",
|
64
|
+
server: nil
|
65
|
+
)
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "does not error" do
|
70
|
+
expect { output }.to_not raise_error
|
71
|
+
|
72
|
+
expect(stderr).not_to match("ERROR")
|
73
|
+
|
74
|
+
aggregate_failures do
|
75
|
+
expect(stdout).to match("id: vol-88878")
|
76
|
+
expect(stdout).to match("status: attached")
|
77
|
+
expect(stdout).to match("created_at: 2023-01-01T01:01Z")
|
78
|
+
expect(stdout).to match("description: A volume for testing")
|
79
|
+
expect(stdout).to match("zone: zon-12345")
|
80
|
+
expect(stdout).to match("size: 10240")
|
81
|
+
expect(stdout).to match("type: network")
|
82
|
+
expect(stdout).to match("server:")
|
83
|
+
expect(stdout).to match("boot: false")
|
84
|
+
expect(stdout).to match("filesystem_label:")
|
85
|
+
expect(stdout).to match("filesystem_type: ext4")
|
86
|
+
expect(stdout).to match("delete_with_server: false")
|
87
|
+
expect(stdout).to match("encrypted: false")
|
88
|
+
expect(stdout).to match("serial: vol-12345")
|
89
|
+
expect(stdout).to match("source:")
|
90
|
+
expect(stdout).to match("image: img-12345")
|
91
|
+
expect(stdout).to match("locked: false")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "brightbox volumes update" do
|
4
|
+
include VolumeHelpers
|
5
|
+
|
6
|
+
let(:output) { FauxIO.new { Brightbox.run(argv) } }
|
7
|
+
let(:stdout) { output.stdout }
|
8
|
+
let(:stderr) { output.stderr }
|
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(
|
15
|
+
status: 200,
|
16
|
+
body: JSON.dump(
|
17
|
+
access_token: "ACCESS-TOKEN",
|
18
|
+
refresh_token: "REFRESH_TOKEN"
|
19
|
+
)
|
20
|
+
)
|
21
|
+
|
22
|
+
Brightbox.config.reauthenticate
|
23
|
+
end
|
24
|
+
|
25
|
+
context "without arguments" do
|
26
|
+
let(:argv) { %w[volumes update] }
|
27
|
+
|
28
|
+
it "does not error" do
|
29
|
+
expect { output }.to_not raise_error
|
30
|
+
|
31
|
+
expect(stderr).to eq("ERROR: You must specify the volume ID as the first argument\n")
|
32
|
+
|
33
|
+
expect(stdout).to match("")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with new options" do
|
38
|
+
let(:argv) { %w[volumes update --name New --desc Testing --serial 12345 vol-908us] }
|
39
|
+
|
40
|
+
before do
|
41
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/volumes/vol-908us")
|
42
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
43
|
+
.to_return(
|
44
|
+
status: 200,
|
45
|
+
body: volume_response(
|
46
|
+
id: "vol-908us",
|
47
|
+
name: "Old",
|
48
|
+
description: nil,
|
49
|
+
delete_with_server: true,
|
50
|
+
serial: "vol-908us"
|
51
|
+
)
|
52
|
+
)
|
53
|
+
.to_return(
|
54
|
+
status: 200,
|
55
|
+
body: volume_response(
|
56
|
+
id: "vol-908us",
|
57
|
+
name: "New",
|
58
|
+
description: "Testing",
|
59
|
+
delete_with_server: true,
|
60
|
+
serial: "12345"
|
61
|
+
)
|
62
|
+
)
|
63
|
+
|
64
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/volumes/vol-908us")
|
65
|
+
.with(query: hash_including(account_id: "acc-12345"),
|
66
|
+
body: {
|
67
|
+
name: "New",
|
68
|
+
description: "Testing",
|
69
|
+
serial: "12345"
|
70
|
+
})
|
71
|
+
.to_return(
|
72
|
+
status: 202,
|
73
|
+
body: volume_response(
|
74
|
+
id: "vol-908us",
|
75
|
+
name: "New",
|
76
|
+
description: "Testing",
|
77
|
+
delete_with_server: true,
|
78
|
+
serial: "12345"
|
79
|
+
)
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "does not error" do
|
84
|
+
expect { output }.to_not raise_error
|
85
|
+
|
86
|
+
expect(stderr).to eq("Updating vol-908us\n")
|
87
|
+
|
88
|
+
aggregate_failures do
|
89
|
+
expect(stdout).to match("vol-908us")
|
90
|
+
expect(stdout).to match("New")
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "with delete-with-server option" do
|
96
|
+
let(:argv) { %w[volumes update --delete-with-server vol-kl234] }
|
97
|
+
|
98
|
+
before do
|
99
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/volumes/vol-kl234")
|
100
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
101
|
+
.to_return(
|
102
|
+
status: 200,
|
103
|
+
body: volume_response(
|
104
|
+
id: "vol-kl234",
|
105
|
+
delete_with_server: false
|
106
|
+
)
|
107
|
+
)
|
108
|
+
.to_return(
|
109
|
+
status: 200,
|
110
|
+
body: volume_response(
|
111
|
+
id: "vol-kl234",
|
112
|
+
delete_with_server: true
|
113
|
+
)
|
114
|
+
)
|
115
|
+
|
116
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/volumes/vol-kl234")
|
117
|
+
.with(query: hash_including(account_id: "acc-12345"),
|
118
|
+
body: {
|
119
|
+
delete_with_server: true
|
120
|
+
})
|
121
|
+
.to_return(
|
122
|
+
status: 202,
|
123
|
+
body: volume_response(
|
124
|
+
id: "vol-kl234",
|
125
|
+
delete_with_server: true
|
126
|
+
)
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
it "does not error" do
|
131
|
+
expect { output }.to_not raise_error
|
132
|
+
|
133
|
+
expect(stderr).to eq("Updating vol-kl234\n")
|
134
|
+
|
135
|
+
aggregate_failures do
|
136
|
+
expect(stdout).to match("vol-kl234")
|
137
|
+
expect(stdout).to match("false")
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context "with no-delete-with-server option" do
|
143
|
+
let(:argv) { %w[volumes update --no-delete-with-server vol-sdj2j] }
|
144
|
+
|
145
|
+
before do
|
146
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/volumes/vol-sdj2j")
|
147
|
+
.with(query: hash_including(account_id: "acc-12345"))
|
148
|
+
.to_return(
|
149
|
+
status: 200,
|
150
|
+
body: volume_response(
|
151
|
+
id: "vol-sdj2j",
|
152
|
+
delete_with_server: true
|
153
|
+
)
|
154
|
+
)
|
155
|
+
.to_return(
|
156
|
+
status: 200,
|
157
|
+
body: volume_response(
|
158
|
+
id: "vol-sdj2j",
|
159
|
+
delete_with_server: false
|
160
|
+
)
|
161
|
+
)
|
162
|
+
|
163
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/volumes/vol-sdj2j")
|
164
|
+
.with(query: hash_including(account_id: "acc-12345"),
|
165
|
+
body: {
|
166
|
+
delete_with_server: false
|
167
|
+
})
|
168
|
+
.to_return(
|
169
|
+
status: 202,
|
170
|
+
body: volume_response(
|
171
|
+
id: "vol-sdj2j",
|
172
|
+
delete_with_server: false
|
173
|
+
)
|
174
|
+
)
|
175
|
+
end
|
176
|
+
|
177
|
+
it "does not error" do
|
178
|
+
expect { output }.to_not raise_error
|
179
|
+
|
180
|
+
expect(stderr).to eq("Updating vol-sdj2j\n")
|
181
|
+
|
182
|
+
aggregate_failures do
|
183
|
+
expect(stdout).to match("vol-sdj2j")
|
184
|
+
expect(stdout).to match("false")
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|