tugboat 1.3.1 → 2.0.0.RC1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +12 -8
- data/lib/tugboat/cli.rb +8 -7
- data/lib/tugboat/config.rb +8 -12
- data/lib/tugboat/middleware/add_key.rb +9 -6
- data/lib/tugboat/middleware/ask_for_credentials.rb +7 -8
- data/lib/tugboat/middleware/check_configuration.rb +1 -1
- data/lib/tugboat/middleware/check_credentials.rb +4 -2
- data/lib/tugboat/middleware/config.rb +3 -4
- data/lib/tugboat/middleware/create_droplet.rb +32 -26
- data/lib/tugboat/middleware/destroy_droplet.rb +6 -6
- data/lib/tugboat/middleware/destroy_image.rb +6 -6
- data/lib/tugboat/middleware/find_droplet.rb +20 -16
- data/lib/tugboat/middleware/find_image.rb +17 -10
- data/lib/tugboat/middleware/halt_droplet.rb +8 -8
- data/lib/tugboat/middleware/info_droplet.rb +38 -25
- data/lib/tugboat/middleware/info_image.rb +5 -5
- data/lib/tugboat/middleware/inject_client.rb +3 -9
- data/lib/tugboat/middleware/list_droplets.rb +6 -4
- data/lib/tugboat/middleware/list_images.rb +28 -23
- data/lib/tugboat/middleware/list_regions.rb +3 -3
- data/lib/tugboat/middleware/list_sizes.rb +3 -3
- data/lib/tugboat/middleware/list_ssh_keys.rb +5 -4
- data/lib/tugboat/middleware/password_reset.rb +7 -7
- data/lib/tugboat/middleware/rebuild_droplet.rb +8 -8
- data/lib/tugboat/middleware/resize_droplet.rb +7 -7
- data/lib/tugboat/middleware/restart_droplet.rb +8 -8
- data/lib/tugboat/middleware/snapshot_droplet.rb +6 -6
- data/lib/tugboat/middleware/ssh_droplet.rb +3 -1
- data/lib/tugboat/middleware/start_droplet.rb +6 -6
- data/lib/tugboat/middleware/wait_for_state.rb +6 -6
- data/lib/tugboat/version.rb +1 -1
- data/spec/cli/add_key_spec.rb +16 -9
- data/spec/cli/authorize_cli_spec.rb +24 -29
- data/spec/cli/config_cli_spec.rb +57 -0
- data/spec/cli/create_cli_spec.rb +18 -28
- data/spec/cli/debug_cli_spec.rb +8 -14
- data/spec/cli/destroy_cli_spec.rb +39 -50
- data/spec/cli/destroy_image_cli_spec.rb +33 -39
- data/spec/cli/droplets_cli_spec.rb +15 -12
- data/spec/cli/halt_cli_spec.rb +50 -46
- data/spec/cli/images_cli_spec.rb +134 -58
- data/spec/cli/info_cli_spec.rb +139 -139
- data/spec/cli/info_image_cli_spec.rb +113 -26
- data/spec/cli/keys_cli_spec.rb +7 -5
- data/spec/cli/password_reset_cli_spec.rb +46 -44
- data/spec/cli/rebuild_cli_spec.rb +187 -101
- data/spec/cli/regions_cli_spec.rb +13 -6
- data/spec/cli/resize_cli_spec.rb +51 -48
- data/spec/cli/restart_cli_spec.rb +41 -39
- data/spec/cli/sizes_cli_spec.rb +13 -8
- data/spec/cli/snapshot_cli_spec.rb +36 -37
- data/spec/cli/ssh_cli_spec.rb +7 -15
- data/spec/cli/start_cli_spec.rb +39 -35
- data/spec/cli/verify_cli_spec.rb +20 -12
- data/spec/cli/wait_cli_spec.rb +43 -27
- data/spec/config_spec.rb +19 -25
- data/spec/fixtures/create_droplet.json +44 -0
- data/spec/fixtures/create_ssh_key.json +4 -4
- data/spec/fixtures/create_ssh_key_from_file.json +8 -0
- data/spec/fixtures/droplet_start_response.json +13 -0
- data/spec/fixtures/not_found.json +4 -0
- data/spec/fixtures/password_reset_response.json +13 -0
- data/spec/fixtures/power_cycle_response.json +13 -0
- data/spec/fixtures/resize_droplet.json +13 -0
- data/spec/fixtures/restart_response.json +13 -0
- data/spec/fixtures/show_coreos_image.json +23 -0
- data/spec/fixtures/show_droplet.json +90 -11
- data/spec/fixtures/show_droplet_inactive.json +90 -11
- data/spec/fixtures/show_droplets.json +249 -30
- data/spec/fixtures/show_droplets_empty.json +5 -2
- data/spec/fixtures/show_image.json +14 -7
- data/spec/fixtures/show_images.json +1075 -13
- data/spec/fixtures/show_images_global.json +25 -16
- data/spec/fixtures/show_keys.json +15 -7
- data/spec/fixtures/show_redmine_image.json +24 -0
- data/spec/fixtures/show_regions.json +181 -12
- data/spec/fixtures/show_sizes.json +178 -9
- data/spec/fixtures/shutdown_response.json +13 -0
- data/spec/fixtures/snapshot_response.json +13 -0
- data/spec/fixtures/ubuntu_image_9801951.json +24 -0
- data/spec/middleware/check_credentials_spec.rb +4 -3
- data/spec/middleware/inject_client_spec.rb +2 -2
- data/spec/shared/environment.rb +6 -7
- data/spec/spec_helper.rb +1 -1
- data/tugboat.gemspec +39 -19
- metadata +50 -14
- data/spec/fixtures/show_droplet_fuzzy.json +0 -13
- data/spec/fixtures/show_droplets_fuzzy.json +0 -35
- data/spec/fixtures/show_droplets_inactive.json +0 -37
@@ -5,79 +5,81 @@ describe Tugboat::CLI do
|
|
5
5
|
|
6
6
|
describe "passwordreset" do
|
7
7
|
it "resets the root password given a fuzzy name" do
|
8
|
-
stub_request(:get, "https://api.digitalocean.com/droplets?
|
9
|
-
|
10
|
-
|
11
|
-
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{"status":"OK","event_id":456}')
|
8
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
9
|
+
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'}).
|
10
|
+
to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
|
12
11
|
|
13
|
-
|
12
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
13
|
+
with(:body => "{\"type\":\"password_reset\"}",
|
14
|
+
: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'}).
|
15
|
+
to_return(:status => 200, :body => fixture('password_reset_response'), :headers => {})
|
16
|
+
|
17
|
+
@cli.password_reset("example.com")
|
14
18
|
|
15
19
|
expect($stdout.string).to eq <<-eos
|
16
|
-
Droplet fuzzy name provided. Finding droplet ID...done\e[0m,
|
17
|
-
Queuing password reset for
|
20
|
+
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
21
|
+
Queuing password reset for 6918990 (example.com)...Password reset successful!
|
18
22
|
Your new root password will be emailed to you
|
19
23
|
eos
|
20
|
-
|
21
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).
|
22
|
-
to have_been_made
|
23
|
-
expect(a_request(:post, "https://api.digitalocean.com/droplets/100823/password_reset?api_key=#{api_key}&client_id=#{client_key}")).
|
24
|
-
to have_been_made
|
25
24
|
end
|
26
25
|
|
27
26
|
it "resets the root password given an id" do
|
28
|
-
stub_request(:get, "https://api.digitalocean.com/droplets
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
28
|
+
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'}).
|
29
|
+
to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
|
30
|
+
|
31
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
|
32
|
+
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'}).
|
33
|
+
to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
|
34
|
+
|
35
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
36
|
+
with(:body => "{\"type\":\"password_reset\"}",
|
37
|
+
: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
|
+
to_return(:status => 200, :body => fixture('password_reset_response'), :headers => {})
|
32
39
|
|
33
|
-
@cli.options = @cli.options.merge(:id =>
|
40
|
+
@cli.options = @cli.options.merge(:id => 6918990)
|
34
41
|
@cli.password_reset
|
35
42
|
|
36
43
|
expect($stdout.string).to eq <<-eos
|
37
|
-
Droplet id provided. Finding Droplet...done\e[0m,
|
38
|
-
Queuing password reset for
|
44
|
+
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
45
|
+
Queuing password reset for 6918990 (example.com)...Password reset successful!
|
39
46
|
Your new root password will be emailed to you
|
40
47
|
eos
|
41
|
-
|
42
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets/100823?api_key=#{api_key}&client_id=#{client_key}")).
|
43
|
-
to have_been_made
|
44
|
-
expect(a_request(:post, "https://api.digitalocean.com/droplets/100823/password_reset?api_key=#{api_key}&client_id=#{client_key}")).
|
45
|
-
to have_been_made
|
46
48
|
end
|
47
49
|
|
48
50
|
it "resets the root password given a name" do
|
49
|
-
stub_request(:get, "https://api.digitalocean.com/droplets?
|
50
|
-
|
51
|
-
|
52
|
-
|
51
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
52
|
+
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'}).
|
53
|
+
to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
|
54
|
+
|
55
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
56
|
+
with(:body => "{\"type\":\"password_reset\"}",
|
57
|
+
: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'}).
|
58
|
+
to_return(:status => 200, :body => fixture('password_reset_response'), :headers => {})
|
53
59
|
|
54
|
-
@cli.options = @cli.options.merge(:name => "
|
60
|
+
@cli.options = @cli.options.merge(:name => "example.com")
|
55
61
|
@cli.password_reset
|
56
62
|
|
57
63
|
expect($stdout.string).to eq <<-eos
|
58
|
-
Droplet name provided. Finding droplet ID...done\e[0m,
|
59
|
-
Queuing password reset for
|
64
|
+
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
65
|
+
Queuing password reset for 6918990 (example.com)...Password reset successful!
|
60
66
|
Your new root password will be emailed to you
|
61
67
|
eos
|
62
|
-
|
63
|
-
expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).
|
64
|
-
to have_been_made
|
65
|
-
expect(a_request(:post, "https://api.digitalocean.com/droplets/100823/password_reset?api_key=#{api_key}&client_id=#{client_key}")).
|
66
|
-
to have_been_made
|
67
68
|
end
|
68
69
|
|
69
70
|
it "raises SystemExit when a request fails" do
|
70
|
-
stub_request(:get, "https://api.digitalocean.com/droplets?
|
71
|
-
|
72
|
-
|
71
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
72
|
+
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'}).
|
73
|
+
to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
|
74
|
+
|
75
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
76
|
+
with(:body => "{\"type\":\"password_reset\"}",
|
77
|
+
: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'}).
|
73
78
|
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 500, :body => '{"status":"ERROR","message":"Some error"}')
|
74
79
|
|
75
|
-
|
80
|
+
@cli.options = @cli.options.merge(:name => "example.com")
|
76
81
|
|
77
|
-
|
78
|
-
to have_been_made
|
79
|
-
expect(a_request(:post, "https://api.digitalocean.com/droplets/100823/password_reset?api_key=#{api_key}&client_id=#{client_key}")).
|
80
|
-
to have_been_made
|
82
|
+
expect{ @cli.password_reset("example.com") }.to raise_error(SystemExit)
|
81
83
|
end
|
82
84
|
end
|
83
85
|
end
|
@@ -4,211 +4,297 @@ describe Tugboat::CLI do
|
|
4
4
|
include_context "spec"
|
5
5
|
|
6
6
|
describe "rebuild" do
|
7
|
-
it "rebuilds a droplet with a fuzzy name based on an image with a
|
8
|
-
stub_request(:get, "https://api.digitalocean.com/droplets?
|
9
|
-
|
7
|
+
it "rebuilds a droplet with a fuzzy name based on an image with a fuzzy name" do
|
8
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
9
|
+
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'}).
|
10
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
10
11
|
|
11
|
-
stub_request(:get, "https://api.digitalocean.com/images?
|
12
|
-
|
12
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
|
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
|
+
to_return(:status => 200, :body => fixture('show_images'), :headers => {})
|
13
15
|
|
14
|
-
stub_request(:post, "https://api.digitalocean.com/droplets/
|
15
|
-
|
16
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
17
|
+
with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
|
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
|
+
to_return(:status => 200, :body => "", :headers => {})
|
16
20
|
|
17
21
|
expect($stdin).to receive(:gets).and_return("y")
|
18
22
|
|
19
|
-
@cli.rebuild("
|
23
|
+
@cli.rebuild("example.com", "ubuntu-14-04-x64")
|
20
24
|
|
21
25
|
expect($stdout.string).to eq <<-eos
|
22
|
-
Droplet fuzzy name provided. Finding droplet ID...done\e[0m,
|
26
|
+
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
27
|
+
Image fuzzy name provided. Finding image ID...done\e[0m, 12790328 (14.04 x64)
|
28
|
+
Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild for droplet 6918990 (example.com) with image 12790328 (14.04 x64)...Rebuild complete
|
23
29
|
eos
|
24
|
-
|
30
|
+
|
25
31
|
end
|
26
32
|
|
27
|
-
it "rebuilds a droplet with an id based on an image with a
|
28
|
-
stub_request(:get, "https://api.digitalocean.com/droplets
|
29
|
-
|
33
|
+
it "rebuilds a droplet with an id based on an image with a fuzzy name" do
|
34
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets/12790328?per_page=200").
|
35
|
+
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'}).
|
36
|
+
to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
|
30
37
|
|
31
|
-
stub_request(:get, "https://api.digitalocean.com/images?
|
32
|
-
|
38
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
|
39
|
+
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'}).
|
40
|
+
to_return(:status => 200, :body => fixture('show_images'), :headers => {})
|
33
41
|
|
34
|
-
stub_request(:post, "https://api.digitalocean.com/droplets/
|
35
|
-
|
42
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
43
|
+
with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
|
44
|
+
: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'}).
|
45
|
+
to_return(:status => 200, :body => "", :headers => {})
|
36
46
|
|
37
47
|
expect($stdin).to receive(:gets).and_return("y")
|
38
48
|
|
39
|
-
@cli.options = @cli.options.merge(:id =>
|
40
|
-
@cli.rebuild("
|
49
|
+
@cli.options = @cli.options.merge(:id => '12790328')
|
50
|
+
@cli.rebuild("example.com","ubuntu-14-04-x64")
|
41
51
|
|
42
52
|
expect($stdout.string).to eq <<-eos
|
43
|
-
Droplet id provided. Finding Droplet...done\e[0m,
|
53
|
+
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
54
|
+
Image fuzzy name provided. Finding image ID...done\e[0m, 12790328 (14.04 x64)
|
55
|
+
Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild for droplet 6918990 (example.com) with image 12790328 (14.04 x64)...Rebuild complete
|
44
56
|
eos
|
45
|
-
expect(a_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478")).to have_been_made
|
46
57
|
end
|
47
58
|
|
48
|
-
it "rebuilds a droplet with a name based on an image with a
|
49
|
-
stub_request(:get, "https://api.digitalocean.com/droplets?
|
50
|
-
|
59
|
+
it "rebuilds a droplet with a name based on an image with a fuzzy name" do
|
60
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
61
|
+
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'}).
|
62
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
63
|
+
|
64
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets/12790328?per_page=200").
|
65
|
+
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'}).
|
66
|
+
to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
|
51
67
|
|
52
|
-
stub_request(:get, "https://api.digitalocean.com/images?
|
53
|
-
|
68
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
|
69
|
+
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'}).
|
70
|
+
to_return(:status => 200, :body => fixture('show_images'), :headers => {})
|
54
71
|
|
55
|
-
stub_request(:post, "https://api.digitalocean.com/droplets/
|
56
|
-
|
72
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
73
|
+
with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
|
74
|
+
: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'}).
|
75
|
+
to_return(:status => 200, :body => "", :headers => {})
|
57
76
|
|
58
77
|
expect($stdin).to receive(:gets).and_return("y")
|
59
78
|
|
60
|
-
@cli.options = @cli.options.merge(:name =>
|
61
|
-
@cli.rebuild("
|
79
|
+
@cli.options = @cli.options.merge(:name => 'example.com')
|
80
|
+
@cli.rebuild("example.com","ubuntu-14-04-x64")
|
62
81
|
|
63
82
|
expect($stdout.string).to eq <<-eos
|
64
|
-
Droplet name provided. Finding droplet ID...done\e[0m,
|
83
|
+
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
84
|
+
Image fuzzy name provided. Finding image ID...done\e[0m, 12790328 (14.04 x64)
|
85
|
+
Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild for droplet 6918990 (example.com) with image 12790328 (14.04 x64)...Rebuild complete
|
65
86
|
eos
|
66
|
-
|
87
|
+
|
67
88
|
end
|
68
89
|
|
69
90
|
it "rebuilds a droplet with a fuzzy name based on an image with an id" do
|
70
|
-
stub_request(:get, "https://api.digitalocean.com/droplets?
|
71
|
-
|
91
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
92
|
+
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'}).
|
93
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
72
94
|
|
73
|
-
stub_request(:get, "https://api.digitalocean.com/
|
74
|
-
|
95
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets/12790328?per_page=200").
|
96
|
+
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'}).
|
97
|
+
to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
|
75
98
|
|
76
|
-
stub_request(:
|
77
|
-
|
99
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
|
100
|
+
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'}).
|
101
|
+
to_return(:status => 200, :body => fixture('show_images'), :headers => {})
|
102
|
+
|
103
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images/12790328?per_page=200").
|
104
|
+
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'}).
|
105
|
+
to_return(:status => 200, :body => fixture('show_image'), :headers => {})
|
106
|
+
|
107
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
108
|
+
with(:body => "{\"type\":\"rebuild\",\"image_id\":6376601}",
|
109
|
+
: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'}).
|
110
|
+
to_return(:status => 200, :body => "", :headers => {})
|
78
111
|
|
79
112
|
expect($stdin).to receive(:gets).and_return("y")
|
80
113
|
|
81
|
-
@cli.options = @cli.options.merge(:image_id =>
|
82
|
-
@cli.rebuild("
|
114
|
+
@cli.options = @cli.options.merge(:image_id => 12790328)
|
115
|
+
@cli.rebuild("example.com","ubuntu-14-04-x64")
|
83
116
|
|
84
117
|
expect($stdout.string).to eq <<-eos
|
85
|
-
Droplet fuzzy name provided. Finding droplet ID...done\e[0m,
|
118
|
+
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
119
|
+
Image id provided. Finding Image...done\e[0m, 6376601 (My application image)
|
120
|
+
Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild for droplet 6918990 (example.com) with image 6376601 (My application image)...Rebuild complete
|
86
121
|
eos
|
87
|
-
expect(a_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478")).to have_been_made
|
88
122
|
end
|
89
123
|
|
90
124
|
it "rebuilds a droplet with an id based on an image with an id" do
|
91
|
-
stub_request(:get, "https://api.digitalocean.com/droplets
|
92
|
-
|
125
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
126
|
+
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'}).
|
127
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
128
|
+
|
129
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets/12790328?per_page=200").
|
130
|
+
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'}).
|
131
|
+
to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
|
93
132
|
|
94
|
-
stub_request(:get, "https://api.digitalocean.com/images
|
95
|
-
|
133
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
|
134
|
+
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'}).
|
135
|
+
to_return(:status => 200, :body => fixture('show_images'), :headers => {})
|
96
136
|
|
97
|
-
stub_request(:
|
98
|
-
|
137
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images/12790328?per_page=200").
|
138
|
+
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'}).
|
139
|
+
to_return(:status => 200, :body => fixture('show_image'), :headers => {})
|
140
|
+
|
141
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
142
|
+
with(:body => "{\"type\":\"rebuild\",\"image_id\":6376601}",
|
143
|
+
: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'}).
|
144
|
+
to_return(:status => 200, :body => "", :headers => {})
|
99
145
|
|
100
146
|
expect($stdin).to receive(:gets).and_return("y")
|
101
147
|
|
102
|
-
@cli.options = @cli.options.merge(:id =>
|
103
|
-
@cli.rebuild("
|
148
|
+
@cli.options = @cli.options.merge(:id => '12790328', :image_id => 12790328)
|
149
|
+
@cli.rebuild("example.com","ubuntu-14-04-x64")
|
104
150
|
|
105
151
|
expect($stdout.string).to eq <<-eos
|
106
|
-
Droplet id provided. Finding Droplet...done\e[0m,
|
152
|
+
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
153
|
+
Image id provided. Finding Image...done\e[0m, 6376601 (My application image)
|
154
|
+
Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild for droplet 6918990 (example.com) with image 6376601 (My application image)...Rebuild complete
|
107
155
|
eos
|
108
|
-
expect(a_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478")).to have_been_made
|
109
156
|
end
|
110
157
|
|
111
158
|
it "rebuilds a droplet with a name based on an image with an id" do
|
112
|
-
stub_request(:get, "https://api.digitalocean.com/droplets?
|
113
|
-
|
159
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
160
|
+
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'}).
|
161
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
162
|
+
|
163
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets/12790328?per_page=200").
|
164
|
+
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'}).
|
165
|
+
to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
|
166
|
+
|
167
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
|
168
|
+
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'}).
|
169
|
+
to_return(:status => 200, :body => fixture('show_images'), :headers => {})
|
114
170
|
|
115
|
-
stub_request(:get, "https://api.digitalocean.com/images/
|
116
|
-
|
171
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images/12790328?per_page=200").
|
172
|
+
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'}).
|
173
|
+
to_return(:status => 200, :body => fixture('show_image'), :headers => {})
|
117
174
|
|
118
|
-
stub_request(:post, "https://api.digitalocean.com/droplets/
|
119
|
-
|
175
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
176
|
+
with(:body => "{\"type\":\"rebuild\",\"image_id\":6376601}",
|
177
|
+
: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'}).
|
178
|
+
to_return(:status => 200, :body => "", :headers => {})
|
120
179
|
|
121
180
|
expect($stdin).to receive(:gets).and_return("y")
|
122
181
|
|
123
|
-
@cli.options = @cli.options.merge(:name =>
|
124
|
-
@cli.rebuild("
|
182
|
+
@cli.options = @cli.options.merge(:name => 'example.com', :image_id => 12790328)
|
183
|
+
@cli.rebuild("example.com","ubuntu-14-04-x64")
|
125
184
|
|
126
185
|
expect($stdout.string).to eq <<-eos
|
127
|
-
Droplet name provided. Finding droplet ID...done\e[0m,
|
186
|
+
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
187
|
+
Image id provided. Finding Image...done\e[0m, 6376601 (My application image)
|
188
|
+
Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild for droplet 6918990 (example.com) with image 6376601 (My application image)...Rebuild complete
|
128
189
|
eos
|
129
|
-
expect(a_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478")).to have_been_made
|
130
190
|
end
|
131
191
|
|
132
192
|
it "rebuilds a droplet with a fuzzy name based on an image with a name" do
|
133
|
-
stub_request(:get, "https://api.digitalocean.com/droplets?
|
134
|
-
|
193
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
194
|
+
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'}).
|
195
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
135
196
|
|
136
|
-
stub_request(:get, "https://api.digitalocean.com/images?
|
137
|
-
|
197
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
|
198
|
+
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'}).
|
199
|
+
to_return(:status => 200, :body => fixture('show_images'), :headers => {})
|
138
200
|
|
139
|
-
stub_request(:post, "https://api.digitalocean.com/droplets/
|
140
|
-
|
201
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
202
|
+
with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
|
203
|
+
: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'}).
|
204
|
+
to_return(:status => 200, :body => "", :headers => {})
|
141
205
|
|
142
206
|
expect($stdin).to receive(:gets).and_return("y")
|
143
207
|
|
144
|
-
@cli.options = @cli.options.merge(:image_name => "
|
145
|
-
|
208
|
+
@cli.options = @cli.options.merge(:image_name => "14.04 x64")
|
209
|
+
|
210
|
+
@cli.rebuild("example.com","ubuntu-14-04-x64")
|
146
211
|
|
147
212
|
expect($stdout.string).to eq <<-eos
|
148
|
-
Droplet fuzzy name provided. Finding droplet ID...done\e[0m,
|
213
|
+
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
214
|
+
Image name provided. Finding Image...done\e[0m, 12790328 (14.04 x64)
|
215
|
+
Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild for droplet 6918990 (example.com) with image 12790328 (14.04 x64)...Rebuild complete
|
149
216
|
eos
|
150
|
-
expect(a_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478")).to have_been_made
|
151
217
|
end
|
152
218
|
|
153
219
|
it "rebuilds a droplet with an id based on an image with a name" do
|
154
|
-
stub_request(:get, "https://api.digitalocean.com/droplets
|
155
|
-
|
220
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
221
|
+
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'}).
|
222
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
223
|
+
|
224
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets/12790328?per_page=200").
|
225
|
+
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'}).
|
226
|
+
to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
|
156
227
|
|
157
|
-
stub_request(:get, "https://api.digitalocean.com/images?
|
158
|
-
|
228
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
|
229
|
+
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'}).
|
230
|
+
to_return(:status => 200, :body => fixture('show_images'), :headers => {})
|
159
231
|
|
160
|
-
stub_request(:post, "https://api.digitalocean.com/droplets/
|
161
|
-
|
232
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
233
|
+
with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
|
234
|
+
: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'}).
|
235
|
+
to_return(:status => 200, :body => "", :headers => {})
|
162
236
|
|
163
237
|
expect($stdin).to receive(:gets).and_return("y")
|
164
238
|
|
165
|
-
@cli.options = @cli.options.merge(:id =>
|
166
|
-
@cli.rebuild("
|
239
|
+
@cli.options = @cli.options.merge(:id => '12790328', :image_name => "14.04 x64")
|
240
|
+
@cli.rebuild("example.com", "14.04 x64")
|
167
241
|
|
168
242
|
expect($stdout.string).to eq <<-eos
|
169
|
-
Droplet id provided. Finding Droplet...done\e[0m,
|
243
|
+
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
244
|
+
Image name provided. Finding Image...done\e[0m, 12790328 (14.04 x64)
|
245
|
+
Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild for droplet 6918990 (example.com) with image 12790328 (14.04 x64)...Rebuild complete
|
170
246
|
eos
|
171
|
-
expect(a_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478")).to have_been_made
|
172
247
|
end
|
173
248
|
|
174
249
|
it "rebuilds a droplet with a name based on an image with a name" do
|
175
|
-
|
176
|
-
|
250
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
251
|
+
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'}).
|
252
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
177
253
|
|
178
|
-
stub_request(:get, "https://api.digitalocean.com/images?
|
179
|
-
|
254
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
|
255
|
+
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'}).
|
256
|
+
to_return(:status => 200, :body => fixture('show_images'), :headers => {})
|
180
257
|
|
181
|
-
stub_request(:post, "https://api.digitalocean.com/droplets/
|
182
|
-
|
258
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
259
|
+
with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
|
260
|
+
: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'}).
|
261
|
+
to_return(:status => 200, :body => "", :headers => {})
|
183
262
|
|
184
263
|
expect($stdin).to receive(:gets).and_return("y")
|
185
264
|
|
186
|
-
@cli.options = @cli.options.merge(:name =>
|
187
|
-
@cli.rebuild("
|
265
|
+
@cli.options = @cli.options.merge(:name => 'example.com', :image_name => "14.04 x64")
|
266
|
+
@cli.rebuild("example.com", "14.04 x64")
|
188
267
|
|
189
268
|
expect($stdout.string).to eq <<-eos
|
190
|
-
Droplet name provided. Finding droplet ID...done\e[0m,
|
269
|
+
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
270
|
+
Image name provided. Finding Image...done\e[0m, 12790328 (14.04 x64)
|
271
|
+
Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild for droplet 6918990 (example.com) with image 12790328 (14.04 x64)...Rebuild complete
|
191
272
|
eos
|
192
|
-
expect(a_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478")).to have_been_made
|
193
273
|
end
|
194
274
|
|
195
275
|
it "rebuilds a droplet with confirm flag set" do
|
196
|
-
stub_request(:get, "https://api.digitalocean.com/droplets?
|
197
|
-
|
276
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
|
277
|
+
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'}).
|
278
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
279
|
+
|
280
|
+
stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
|
281
|
+
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'}).
|
282
|
+
to_return(:status => 200, :body => fixture('show_images'), :headers => {})
|
198
283
|
|
199
|
-
stub_request(:
|
200
|
-
|
284
|
+
stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
|
285
|
+
with(:body => "{\"type\":\"rebuild\",\"image_id\":12790328}",
|
286
|
+
: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'}).
|
287
|
+
to_return(:status => 200, :body => "", :headers => {})
|
201
288
|
|
202
|
-
stub_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478").
|
203
|
-
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{ "status": "OK", "event_id": 7504 }')
|
204
289
|
|
205
290
|
@cli.options = @cli.options.merge(:confirm => "no")
|
206
|
-
@cli.rebuild("
|
291
|
+
@cli.rebuild("example.com", "14.04 x64")
|
207
292
|
|
208
293
|
expect($stdout.string).to eq <<-eos
|
209
|
-
Droplet fuzzy name provided. Finding droplet ID...done\e[0m,
|
294
|
+
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
295
|
+
Image fuzzy name provided. Finding image ID...done\e[0m, 12790328 (14.04 x64)
|
296
|
+
Queuing rebuild for droplet 6918990 (example.com) with image 12790328 (14.04 x64)...Rebuild complete
|
210
297
|
eos
|
211
|
-
expect(a_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478")).to have_been_made
|
212
298
|
end
|
213
299
|
end
|
214
300
|
|