tugboat 3.1.0 → 4.0.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 +22 -1
- data/CODE_OF_CONDUCT.md +46 -0
- data/lib/tugboat/cli.rb +7 -1
- data/lib/tugboat/config.rb +11 -1
- data/lib/tugboat/middleware.rb +2 -0
- data/lib/tugboat/middleware/ask_for_credentials.rb +2 -1
- data/lib/tugboat/middleware/base.rb +31 -13
- data/lib/tugboat/middleware/check_snapshot_parameters.rb +16 -0
- data/lib/tugboat/middleware/info_droplet.rb +2 -2
- data/lib/tugboat/middleware/inject_client.rb +10 -1
- data/lib/tugboat/middleware/list_droplets.rb +5 -3
- data/lib/tugboat/version.rb +1 -1
- data/spec/cli/add_key_spec.rb +7 -9
- data/spec/cli/authorize_cli_spec.rb +4 -34
- data/spec/cli/config_cli_spec.rb +10 -5
- data/spec/cli/create_cli_spec.rb +20 -17
- data/spec/cli/debug_cli_spec.rb +11 -12
- data/spec/cli/destroy_cli_spec.rb +35 -12
- data/spec/cli/destroy_image_cli_spec.rb +12 -10
- data/spec/cli/droplets_cli_spec.rb +74 -48
- data/spec/cli/env_variable_spec.rb +4 -4
- data/spec/cli/halt_cli_spec.rb +16 -13
- data/spec/cli/help_cli_spec.rb +4 -4
- data/spec/cli/images_cli_spec.rb +9 -7
- data/spec/cli/info_cli_spec.rb +120 -50
- data/spec/cli/info_image_cli_spec.rb +24 -23
- data/spec/cli/keys_cli_spec.rb +3 -3
- data/spec/cli/password_reset_cli_spec.rb +12 -12
- data/spec/cli/rebuild_cli_spec.rb +31 -24
- data/spec/cli/regions_cli_spec.rb +3 -3
- data/spec/cli/resize_cli_spec.rb +16 -16
- data/spec/cli/restart_cli_spec.rb +32 -11
- data/spec/cli/sizes_cli_spec.rb +3 -3
- data/spec/cli/snapshot_cli_spec.rb +25 -9
- data/spec/cli/ssh_cli_spec.rb +10 -10
- data/spec/cli/start_cli_spec.rb +15 -15
- data/spec/cli/verify_cli_spec.rb +4 -7
- data/spec/cli/version_cli_spec.rb +1 -2
- data/spec/cli/wait_cli_spec.rb +16 -16
- data/spec/config_spec.rb +7 -1
- data/spec/fixtures/show_droplets.json +7 -4
- data/spec/fixtures/show_droplets_paginated_first.json +10 -7
- data/spec/fixtures/show_droplets_paginated_last.json +11 -5
- data/spec/fixtures/show_droplets_private_ip.json +7 -4
- data/spec/middleware/base_spec.rb +1 -2
- data/spec/middleware/check_configuration_spec.rb +1 -1
- data/spec/middleware/check_credentials_spec.rb +1 -1
- data/spec/middleware/check_droplet_active_spec.rb +1 -1
- data/spec/middleware/check_droplet_inactive_spec.rb +1 -1
- data/spec/middleware/find_droplet_spec.rb +3 -5
- data/spec/middleware/find_image_spec.rb +3 -5
- data/spec/middleware/ssh_droplet_spec.rb +5 -10
- data/spec/shared/environment.rb +2 -18
- data/tugboat.gemspec +1 -2
- metadata +8 -6
@@ -15,8 +15,8 @@ describe Tugboat::CLI do
|
|
15
15
|
allow(ENV).to receive(:[]).with('DEBUG').and_return(nil)
|
16
16
|
allow(ENV).to receive(:[]).with('THOR_SHELL').and_return(nil)
|
17
17
|
|
18
|
-
|
19
|
-
expect
|
18
|
+
expected_string = "Authentication with DigitalOcean was successful.\n"
|
19
|
+
expect { cli.verify }.to output(expected_string).to_stdout
|
20
20
|
expect(a_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1')).to have_been_made
|
21
21
|
end
|
22
22
|
|
@@ -31,8 +31,8 @@ describe Tugboat::CLI do
|
|
31
31
|
allow(ENV).to receive(:[]).with('DEBUG').and_return(nil)
|
32
32
|
allow(ENV).to receive(:[]).with('THOR_SHELL').and_return(nil)
|
33
33
|
|
34
|
-
|
35
|
-
expect
|
34
|
+
expected_string = "Authentication with DigitalOcean was successful.\n"
|
35
|
+
expect { cli.verify }.to output(expected_string).to_stdout
|
36
36
|
expect(a_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1')).to have_been_made
|
37
37
|
end
|
38
38
|
end
|
data/spec/cli/halt_cli_spec.rb
CHANGED
@@ -18,12 +18,12 @@ describe Tugboat::CLI do
|
|
18
18
|
headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
19
19
|
to_return(status: 200, body: fixture('shutdown_response'), headers: {})
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
expect($stdout.string).to eq <<-eos
|
21
|
+
expected_string = <<-eos
|
24
22
|
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
25
23
|
Queuing shutdown for 6918990 (example.com)...Halt successful!
|
26
24
|
eos
|
25
|
+
|
26
|
+
expect { cli.halt('example.com') }.to output(expected_string).to_stdout
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'halts a droplet hard when the hard option is used' do
|
@@ -41,12 +41,13 @@ Queuing shutdown for 6918990 (example.com)...Halt successful!
|
|
41
41
|
to_return(status: 200, body: '', headers: {})
|
42
42
|
|
43
43
|
cli.options = cli.options.merge(hard: true)
|
44
|
-
cli.halt('example.com')
|
45
44
|
|
46
|
-
|
45
|
+
expected_string = <<-eos
|
47
46
|
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
48
47
|
Queuing hard shutdown for 6918990 (example.com)...Halt successful!
|
49
48
|
eos
|
49
|
+
|
50
|
+
expect { cli.halt('example.com') }.to output(expected_string).to_stdout
|
50
51
|
end
|
51
52
|
|
52
53
|
it 'halts a droplet with an id' do
|
@@ -68,12 +69,13 @@ Queuing hard shutdown for 6918990 (example.com)...Halt successful!
|
|
68
69
|
to_return(status: 200, body: fixture('shutdown_response'), headers: {})
|
69
70
|
|
70
71
|
cli.options = cli.options.merge(id: '6918990')
|
71
|
-
cli.halt
|
72
72
|
|
73
|
-
|
73
|
+
expected_string = <<-eos
|
74
74
|
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
75
75
|
Queuing shutdown for 6918990 (example.com)...Halt successful!
|
76
76
|
eos
|
77
|
+
|
78
|
+
expect { cli.halt }.to output(expected_string).to_stdout
|
77
79
|
end
|
78
80
|
|
79
81
|
it 'halts a droplet with a name' do
|
@@ -91,12 +93,13 @@ Queuing shutdown for 6918990 (example.com)...Halt successful!
|
|
91
93
|
to_return(status: 200, body: fixture('shutdown_response'), headers: {})
|
92
94
|
|
93
95
|
cli.options = cli.options.merge(name: 'example.com')
|
94
|
-
cli.halt
|
95
96
|
|
96
|
-
|
97
|
+
expected_string = <<-eos
|
97
98
|
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
98
99
|
Queuing shutdown for 6918990 (example.com)...Halt successful!
|
99
100
|
eos
|
101
|
+
|
102
|
+
expect { cli.halt }.to output(expected_string).to_stdout
|
100
103
|
end
|
101
104
|
|
102
105
|
it 'does not halt a droplet that is off' do
|
@@ -108,13 +111,13 @@ Queuing shutdown for 6918990 (example.com)...Halt successful!
|
|
108
111
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
109
112
|
to_return(status: 200, body: fixture('show_droplets'), headers: { 'Content-Type' => 'application/json' })
|
110
113
|
|
111
|
-
|
112
|
-
expect { cli.halt }.to raise_error(SystemExit)
|
113
|
-
|
114
|
-
expect($stdout.string).to eq <<-eos
|
114
|
+
expected_string = <<-eos
|
115
115
|
Droplet name provided. Finding droplet ID...done\e[0m, 3164444 (example3.com)
|
116
116
|
Droplet must be on for this operation to be successful.
|
117
117
|
eos
|
118
|
+
|
119
|
+
cli.options = cli.options.merge(name: 'example3.com')
|
120
|
+
expect { cli.halt }.to raise_error(SystemExit).and output(expected_string).to_stdout
|
118
121
|
end
|
119
122
|
end
|
120
123
|
end
|
data/spec/cli/help_cli_spec.rb
CHANGED
@@ -5,13 +5,13 @@ describe Tugboat::CLI do
|
|
5
5
|
|
6
6
|
describe 'help' do
|
7
7
|
it 'shows a help message' do
|
8
|
-
|
9
|
-
expect
|
8
|
+
expected_string = %r{To learn more or to contribute, please see}
|
9
|
+
expect { cli.help }.to output(expected_string).to_stdout
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'shows a help message for specific commands' do
|
13
|
-
|
14
|
-
expect
|
13
|
+
expected_string = %r{Show available droplet sizes}
|
14
|
+
expect { cli.help 'sizes' }.to output(expected_string).to_stdout
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/spec/cli/images_cli_spec.rb
CHANGED
@@ -13,9 +13,7 @@ describe Tugboat::CLI do
|
|
13
13
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
14
14
|
to_return(status: 200, body: fixture('show_images_global'), headers: {})
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
expect($stdout.string).to eq <<-eos
|
16
|
+
expected_string = <<-eos
|
19
17
|
Showing both private and public images
|
20
18
|
Private Images:
|
21
19
|
My application image (id: 6376601, distro: Ubuntu)
|
@@ -71,6 +69,8 @@ MediaWiki 1.24.2 on 14.04 (slug: mediawiki, id: 11716043, distro: Ubuntu)
|
|
71
69
|
PHPMyAdmin on 14.04 (slug: phpmyadmin, id: 11730661, distro: Ubuntu)
|
72
70
|
Redmine on 14.04 (slug: redmine, id: 12438838, distro: Ubuntu)
|
73
71
|
eos
|
72
|
+
|
73
|
+
expect { cli.images }.to output(expected_string).to_stdout
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'acknowledges when personal images are empty when showing default full list' do
|
@@ -83,9 +83,8 @@ Redmine on 14.04 (slug: redmine, id: 12438838, distro: Ubuntu)
|
|
83
83
|
to_return(status: 200, body: fixture('show_images_empty'), headers: {})
|
84
84
|
|
85
85
|
cli.options = cli.options.merge(show_private_images: true)
|
86
|
-
cli.images
|
87
86
|
|
88
|
-
|
87
|
+
expected_string = <<-eos
|
89
88
|
Showing both private and public images
|
90
89
|
Private Images:
|
91
90
|
No private images found
|
@@ -141,6 +140,8 @@ MediaWiki 1.24.2 on 14.04 (slug: mediawiki, id: 11716043, distro: Ubuntu)
|
|
141
140
|
PHPMyAdmin on 14.04 (slug: phpmyadmin, id: 11730661, distro: Ubuntu)
|
142
141
|
Redmine on 14.04 (slug: redmine, id: 12438838, distro: Ubuntu)
|
143
142
|
eos
|
143
|
+
|
144
|
+
expect { cli.images }.to output(expected_string).to_stdout
|
144
145
|
end
|
145
146
|
|
146
147
|
it 'acknowledges when personal images are empty when just show private images flag given' do
|
@@ -153,13 +154,14 @@ Redmine on 14.04 (slug: redmine, id: 12438838, distro: Ubuntu)
|
|
153
154
|
to_return(status: 200, body: fixture('show_images_empty'), headers: {})
|
154
155
|
|
155
156
|
cli.options = cli.options.merge(show_just_private_images: true)
|
156
|
-
cli.images
|
157
157
|
|
158
|
-
|
158
|
+
expected_string = <<-eos
|
159
159
|
Showing just private images
|
160
160
|
Private Images:
|
161
161
|
No private images found
|
162
162
|
eos
|
163
|
+
|
164
|
+
expect { cli.images }.to output(expected_string).to_stdout
|
163
165
|
end
|
164
166
|
end
|
165
167
|
end
|
data/spec/cli/info_cli_spec.rb
CHANGED
@@ -15,12 +15,12 @@ describe Tugboat::CLI do
|
|
15
15
|
|
16
16
|
cli.options = cli.options.merge(id: 6_918_990)
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
expect($stdout.string).to eq <<-eos
|
18
|
+
expected_string = <<-eos
|
21
19
|
Droplet id provided. Finding Droplet...Failed to find Droplet: The resource you were accessing could not be found.
|
22
20
|
eos
|
23
21
|
|
22
|
+
expect { cli.info }.to raise_error(SystemExit).and output(expected_string).to_stdout
|
23
|
+
|
24
24
|
expect(a_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200')).to have_been_made
|
25
25
|
end
|
26
26
|
|
@@ -37,9 +37,7 @@ Droplet id provided. Finding Droplet...Failed to find Droplet: The resource you
|
|
37
37
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
38
38
|
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
expect($stdout.string).to eq <<-eos
|
40
|
+
expected_string = <<-eos
|
43
41
|
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
44
42
|
|
45
43
|
Name: example.com
|
@@ -52,6 +50,8 @@ Image: 6918990 - ubuntu-14-04-x64
|
|
52
50
|
Size: 512MB
|
53
51
|
Backups Active: false
|
54
52
|
eos
|
53
|
+
|
54
|
+
expect { cli.info('example.com') }.to output(expected_string).to_stdout
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'shows a droplet made from a user image' do
|
@@ -63,10 +63,7 @@ Backups Active: false
|
|
63
63
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
64
64
|
to_return(status: 200, body: fixture('show_droplet_user_image'), headers: {})
|
65
65
|
|
66
|
-
|
67
|
-
cli.info
|
68
|
-
|
69
|
-
expect($stdout.string).to eq <<-eos
|
66
|
+
expected_string = <<-eos
|
70
67
|
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
71
68
|
|
72
69
|
Name: example.com
|
@@ -79,6 +76,9 @@ Image: 36646276 - Super Cool Custom Image
|
|
79
76
|
Size: 512MB
|
80
77
|
Backups Active: false
|
81
78
|
eos
|
79
|
+
|
80
|
+
cli.options = cli.options.merge(id: 6_918_990)
|
81
|
+
expect { cli.info }.to output(expected_string).to_stdout
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'shows a droplet with an id' do
|
@@ -90,10 +90,7 @@ Backups Active: false
|
|
90
90
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
91
91
|
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
92
92
|
|
93
|
-
|
94
|
-
cli.info
|
95
|
-
|
96
|
-
expect($stdout.string).to eq <<-eos
|
93
|
+
expected_string = <<-eos
|
97
94
|
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
98
95
|
|
99
96
|
Name: example.com
|
@@ -106,6 +103,9 @@ Image: 6918990 - ubuntu-14-04-x64
|
|
106
103
|
Size: 512MB
|
107
104
|
Backups Active: false
|
108
105
|
eos
|
106
|
+
|
107
|
+
cli.options = cli.options.merge(id: 6_918_990)
|
108
|
+
expect { cli.info }.to output(expected_string).to_stdout
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'shows a droplet with a name' do
|
@@ -121,10 +121,7 @@ Backups Active: false
|
|
121
121
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
122
122
|
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
123
123
|
|
124
|
-
|
125
|
-
cli.info
|
126
|
-
|
127
|
-
expect($stdout.string).to eq <<-eos
|
124
|
+
expected_string = <<-eos
|
128
125
|
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
129
126
|
|
130
127
|
Name: example.com
|
@@ -137,6 +134,9 @@ Image: 6918990 - ubuntu-14-04-x64
|
|
137
134
|
Size: 512MB
|
138
135
|
Backups Active: false
|
139
136
|
eos
|
137
|
+
|
138
|
+
cli.options = cli.options.merge(name: 'example.com')
|
139
|
+
expect { cli.info }.to output(expected_string).to_stdout
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'allows choice of multiple droplets' do
|
@@ -154,9 +154,7 @@ Backups Active: false
|
|
154
154
|
|
155
155
|
expect($stdin).to receive(:gets).and_return('0')
|
156
156
|
|
157
|
-
|
158
|
-
|
159
|
-
expect($stdout.string).to eq <<-eos
|
157
|
+
expected_string = <<-eos
|
160
158
|
Droplet fuzzy name provided. Finding droplet ID...Multiple droplets found.
|
161
159
|
|
162
160
|
0) example.com (6918990)
|
@@ -174,6 +172,8 @@ Image: 6918990 - ubuntu-14-04-x64
|
|
174
172
|
Size: 512MB
|
175
173
|
Backups Active: false
|
176
174
|
eos
|
175
|
+
|
176
|
+
expect { cli.info('examp') }.to output(expected_string).to_stdout
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
@@ -186,10 +186,7 @@ Backups Active: false
|
|
186
186
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
187
187
|
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
188
188
|
|
189
|
-
|
190
|
-
cli.info
|
191
|
-
|
192
|
-
expect($stdout.string).to eq <<-eos
|
189
|
+
expected_string = <<-eos
|
193
190
|
name example.com
|
194
191
|
id 6918990
|
195
192
|
status active
|
@@ -200,6 +197,9 @@ image 6918990
|
|
200
197
|
size 512mb
|
201
198
|
backups_active false
|
202
199
|
eos
|
200
|
+
|
201
|
+
cli.options = cli.options.merge(id: '6918990', porcelain: true)
|
202
|
+
expect { cli.info }.to output(expected_string).to_stdout
|
203
203
|
end
|
204
204
|
|
205
205
|
it 'shows a droplet with a name under porcelain mode' do
|
@@ -215,10 +215,7 @@ backups_active false
|
|
215
215
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
216
216
|
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
217
217
|
|
218
|
-
|
219
|
-
cli.info
|
220
|
-
|
221
|
-
expect($stdout.string).to eq <<-eos
|
218
|
+
expected_string = <<-eos
|
222
219
|
name example.com
|
223
220
|
id 6918990
|
224
221
|
status active
|
@@ -229,24 +226,45 @@ image 6918990
|
|
229
226
|
size 512mb
|
230
227
|
backups_active false
|
231
228
|
eos
|
229
|
+
|
230
|
+
cli.options = cli.options.merge(name: 'example.com', porcelain: true)
|
231
|
+
expect { cli.info }.to output(expected_string).to_stdout
|
232
232
|
end
|
233
233
|
|
234
|
-
it '
|
234
|
+
it 'throws an error if no id or name provided when using porcelain' do
|
235
235
|
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
236
236
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
237
237
|
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
238
238
|
|
239
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
240
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
241
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
242
|
+
|
239
243
|
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
240
244
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
241
245
|
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
242
246
|
|
243
|
-
cli.options = cli.options.merge(
|
244
|
-
cli.info
|
247
|
+
cli.options = cli.options.merge(porcelain: true)
|
245
248
|
|
246
|
-
expect(
|
249
|
+
expect { cli.info('example.com') }.to raise_error(SystemExit).and output(/Tugboat expects an exact droplet ID or droplet name for porcelain mode/).to_stdout
|
250
|
+
end
|
251
|
+
|
252
|
+
it 'shows a droplet attribute with an id' do
|
253
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
254
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
255
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
256
|
+
|
257
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
258
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
259
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
260
|
+
|
261
|
+
expected_string = <<-eos
|
247
262
|
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
248
263
|
104.131.186.241
|
249
264
|
eos
|
265
|
+
|
266
|
+
cli.options = cli.options.merge(id: '6918990', attribute: 'ip4')
|
267
|
+
expect { cli.info }.to output(expected_string).to_stdout
|
250
268
|
end
|
251
269
|
|
252
270
|
it 'shows a droplet attribute with a name' do
|
@@ -262,13 +280,13 @@ Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
|
262
280
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
263
281
|
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
264
282
|
|
265
|
-
|
266
|
-
cli.info
|
267
|
-
|
268
|
-
expect($stdout.string).to eq <<-eos
|
283
|
+
expected_string = <<-eos
|
269
284
|
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
270
285
|
104.131.186.241
|
271
286
|
eos
|
287
|
+
|
288
|
+
cli.options = cli.options.merge(name: 'example.com', attribute: 'ip4')
|
289
|
+
expect { cli.info }.to output(expected_string).to_stdout
|
272
290
|
end
|
273
291
|
|
274
292
|
it 'gives error if invalid attribute given' do
|
@@ -280,10 +298,7 @@ Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
|
280
298
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
281
299
|
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
282
300
|
|
283
|
-
|
284
|
-
expect { cli.info }.to raise_error(SystemExit)
|
285
|
-
|
286
|
-
expect($stdout.string).to eq <<-eos
|
301
|
+
expected_string = <<-eos
|
287
302
|
Invalid attribute "foo"
|
288
303
|
Provide one of the following:
|
289
304
|
name
|
@@ -297,6 +312,9 @@ Provide one of the following:
|
|
297
312
|
size
|
298
313
|
backups_active
|
299
314
|
eos
|
315
|
+
|
316
|
+
cli.options = cli.options.merge(id: 6_918_990, porcelain: true, attribute: 'foo')
|
317
|
+
expect { expect { cli.info }.to raise_error(SystemExit) }.to output(expected_string).to_stdout
|
300
318
|
end
|
301
319
|
|
302
320
|
it 'shows a droplet attribute with an id under porcelain mode' do
|
@@ -304,12 +322,12 @@ Provide one of the following:
|
|
304
322
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
305
323
|
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
306
324
|
|
307
|
-
|
308
|
-
cli.info
|
309
|
-
|
310
|
-
expect($stdout.string).to eq <<-eos
|
325
|
+
expected_string = <<-eos
|
311
326
|
104.131.186.241
|
312
|
-
|
327
|
+
eos
|
328
|
+
|
329
|
+
cli.options = cli.options.merge(id: '6918990', porcelain: true, attribute: 'ip4')
|
330
|
+
expect { cli.info }.to output(expected_string).to_stdout
|
313
331
|
end
|
314
332
|
|
315
333
|
it 'shows a droplet attribute with a name under porcelain mode' do
|
@@ -325,11 +343,63 @@ Provide one of the following:
|
|
325
343
|
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
326
344
|
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
327
345
|
|
328
|
-
|
329
|
-
cli.info
|
330
|
-
|
331
|
-
expect($stdout.string).to eq <<-eos
|
346
|
+
expected_string = <<-eos
|
332
347
|
104.131.186.241
|
333
348
|
eos
|
349
|
+
|
350
|
+
cli.options = cli.options.merge(name: 'example.com', porcelain: true, attribute: 'ip4')
|
351
|
+
expect { cli.info }.to output(expected_string).to_stdout
|
352
|
+
end
|
353
|
+
|
354
|
+
it 'shows a droplet without a network not ready yet' do
|
355
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
356
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
357
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
358
|
+
|
359
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
360
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
361
|
+
to_return(status: 200, body: fixture('droplet_no_network'), headers: {})
|
362
|
+
|
363
|
+
expected_string = <<-eos
|
364
|
+
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
365
|
+
|
366
|
+
Name: example.com
|
367
|
+
ID: 6918990
|
368
|
+
Status: \e[32mactive\e[0m
|
369
|
+
Region: London 1 - lon1
|
370
|
+
Image: 13089493 - ubuntu-14-04-x64
|
371
|
+
Size: 512MB
|
372
|
+
Backups Active: false
|
373
|
+
eos
|
374
|
+
|
375
|
+
cli.options = cli.options.merge(id: 6_918_990)
|
376
|
+
expect { cli.info }.to output(expected_string).to_stdout
|
377
|
+
end
|
378
|
+
|
379
|
+
it 'shows a droplet that is inactive' do
|
380
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
381
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
382
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
383
|
+
|
384
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/3164494?per_page=200').
|
385
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.9.2' }).
|
386
|
+
to_return(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_droplet_inactive'))
|
387
|
+
|
388
|
+
expected_string = <<-eos
|
389
|
+
Droplet id provided. Finding Droplet...done\e[0m, 3164494 (example.com)
|
390
|
+
|
391
|
+
Name: example.com
|
392
|
+
ID: 3164494
|
393
|
+
Status: \e[31moff\e[0m
|
394
|
+
IP4: 104.131.186.241
|
395
|
+
IP6: 2604:A880:0800:0010:0000:0000:031D:2001
|
396
|
+
Region: New York 3 - nyc3
|
397
|
+
Image: 6918990 - ubuntu-14-04-x64
|
398
|
+
Size: 512MB
|
399
|
+
Backups Active: false
|
400
|
+
eos
|
401
|
+
|
402
|
+
cli.options = cli.options.merge(id: 3164494)
|
403
|
+
expect { cli.info }.to output(expected_string).to_stdout
|
334
404
|
end
|
335
405
|
end
|