vagrant-proxmox 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sanity_checks.rb +1 -1
  3. data/lib/vagrant-proxmox.rb +1 -2
  4. data/lib/vagrant-proxmox/action.rb +133 -86
  5. data/lib/vagrant-proxmox/action/connect_proxmox.rb +10 -10
  6. data/lib/vagrant-proxmox/action/create_vm.rb +33 -28
  7. data/lib/vagrant-proxmox/action/destroy_vm.rb +10 -6
  8. data/lib/vagrant-proxmox/action/get_node_list.rb +8 -6
  9. data/lib/vagrant-proxmox/action/is_created.rb +1 -0
  10. data/lib/vagrant-proxmox/action/is_stopped.rb +1 -0
  11. data/lib/vagrant-proxmox/action/message_file_not_found.rb +21 -0
  12. data/lib/vagrant-proxmox/action/message_not_running.rb +20 -0
  13. data/lib/vagrant-proxmox/action/message_upload_server_error.rb +20 -0
  14. data/lib/vagrant-proxmox/action/proxmox_action.rb +6 -22
  15. data/lib/vagrant-proxmox/action/read_ssh_info.rb +1 -0
  16. data/lib/vagrant-proxmox/action/read_state.rb +11 -14
  17. data/lib/vagrant-proxmox/action/select_node.rb +23 -0
  18. data/lib/vagrant-proxmox/action/shutdown_vm.rb +8 -8
  19. data/lib/vagrant-proxmox/action/start_vm.rb +20 -12
  20. data/lib/vagrant-proxmox/action/stop_vm.rb +9 -8
  21. data/lib/vagrant-proxmox/action/sync_folders.rb +1 -1
  22. data/lib/vagrant-proxmox/action/upload_iso_file.rb +38 -0
  23. data/lib/vagrant-proxmox/action/upload_template_file.rb +38 -0
  24. data/lib/vagrant-proxmox/config.rb +85 -5
  25. data/lib/vagrant-proxmox/errors.rb +22 -2
  26. data/lib/vagrant-proxmox/plugin.rb +0 -14
  27. data/lib/vagrant-proxmox/proxmox/connection.rb +217 -0
  28. data/lib/vagrant-proxmox/proxmox/errors.rb +23 -0
  29. data/lib/vagrant-proxmox/version.rb +1 -1
  30. data/locales/en.yml +29 -2
  31. data/spec/actions/cleanup_after_destroy_action_spec.rb +2 -2
  32. data/spec/actions/connect_proxmox_action_spec.rb +32 -15
  33. data/spec/actions/create_vm_action_spec.rb +155 -130
  34. data/spec/actions/destroy_vm_action_spec.rb +50 -23
  35. data/spec/actions/get_node_list_action_spec.rb +25 -12
  36. data/spec/actions/is_created_action_spec.rb +8 -8
  37. data/spec/actions/is_stopped_action_spec.rb +8 -8
  38. data/spec/actions/message_already_running_action_spec.rb +2 -2
  39. data/spec/actions/message_already_stopped_action_spec.rb +2 -2
  40. data/spec/actions/message_file_not_found_spec.rb +23 -0
  41. data/spec/actions/message_not_created_action_spec.rb +2 -2
  42. data/spec/actions/message_not_running_action_spec.rb +23 -0
  43. data/spec/actions/message_upload_server_error_spec.rb +23 -0
  44. data/spec/actions/proxmox_action_shared.rb +0 -64
  45. data/spec/actions/proxmox_action_spec.rb +57 -0
  46. data/spec/actions/read_ssh_info_action_spec.rb +6 -6
  47. data/spec/actions/read_state_action_spec.rb +36 -34
  48. data/spec/actions/select_node_spec.rb +33 -0
  49. data/spec/actions/shutdown_vm_action_spec.rb +50 -22
  50. data/spec/actions/start_vm_action_spec.rb +87 -33
  51. data/spec/actions/stop_vm_action_spec.rb +50 -23
  52. data/spec/actions/sync_folders_action_spec.rb +9 -9
  53. data/spec/actions/upload_iso_file_action_spec.rb +70 -0
  54. data/spec/actions/upload_template_file_action_spec.rb +70 -0
  55. data/spec/commands/destroy_command_spec.rb +25 -25
  56. data/spec/commands/halt_command_spec.rb +17 -17
  57. data/spec/commands/provision_command_spec.rb +22 -9
  58. data/spec/commands/ssh_command_spec.rb +18 -5
  59. data/spec/commands/ssh_run_command_spec.rb +19 -6
  60. data/spec/commands/status_command_spec.rb +2 -2
  61. data/spec/commands/up_command_spec.rb +174 -34
  62. data/spec/config_spec.rb +325 -46
  63. data/spec/plugin_spec.rb +1 -8
  64. data/spec/provider_spec.rb +4 -4
  65. data/spec/proxmox/connection_spec.rb +662 -0
  66. data/spec/proxmox/rest_call_shared.rb +41 -0
  67. data/spec/sanity_checks_spec.rb +1 -1
  68. data/spec/spec_helper.rb +15 -97
  69. data/spec/spec_helpers/common_helpers.rb +111 -0
  70. data/spec/spec_helpers/time_helpers.rb +90 -0
  71. metadata +161 -45
@@ -6,7 +6,7 @@ describe VagrantPlugins::Proxmox::Action::ReadSSHInfo do
6
6
  let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
7
  let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox)} }
8
8
 
9
- subject { described_class.new(-> (_) {}, environment) }
9
+ subject(:action) { described_class.new(-> (_) {}, environment) }
10
10
 
11
11
  describe '#call' do
12
12
 
@@ -14,16 +14,16 @@ describe VagrantPlugins::Proxmox::Action::ReadSSHInfo do
14
14
 
15
15
  context 'when no ip address is configured' do
16
16
  it 'should write no ssh info into env[:machine_ssh_info]' do
17
- subject.call env
18
- env[:machine_ssh_info].should == nil
17
+ action.call env
18
+ expect(env[:machine_ssh_info]).to eq(nil)
19
19
  end
20
20
  end
21
21
 
22
22
  context 'when an ip address is configured' do
23
- before { env[:machine].config.vm.stub(:networks) { [[:public_network, {ip: '127.0.0.1'}]] } }
23
+ before { allow(env[:machine].config.vm).to receive(:networks) { [[:public_network, {ip: '127.0.0.1'}]] } }
24
24
  it 'should write the ssh info into env[:machine_ssh_info]' do
25
- subject.call env
26
- env[:machine_ssh_info].should == {host: '127.0.0.1', port: 22}
25
+ action.call env
26
+ expect(env[:machine_ssh_info]).to eq({host: '127.0.0.1', port: 22})
27
27
  end
28
28
  end
29
29
 
@@ -1,52 +1,54 @@
1
1
  require 'spec_helper'
2
2
  require 'actions/proxmox_action_shared'
3
3
 
4
- describe VagrantPlugins::Proxmox::Action::ReadState do
4
+ module VagrantPlugins::Proxmox
5
5
 
6
- let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
- let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox)} }
6
+ describe VagrantPlugins::Proxmox::Action::ReadState do
8
7
 
9
- subject { described_class.new(-> (_) {}, environment) }
8
+ let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
9
+ let(:connection) { Connection.new 'https://proxmox.example.com/api2/json' }
10
+ let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox), proxmox_connection: connection} }
11
+ let(:node) { 'localhost' }
12
+ let(:vm_id) { '100' }
13
+ let(:machine_id) { "#{node}/#{vm_id}" }
10
14
 
11
- describe '#call' do
15
+ subject(:action) { described_class.new(-> (_) {}, environment) }
12
16
 
13
- it_behaves_like 'a proxmox action call'
17
+ before do
18
+ allow(env[:machine]).to receive(:id) { machine_id }
19
+ allow(connection).to receive :get_vm_state
20
+ end
21
+
22
+ describe '#call' do
14
23
 
15
- context 'when no machine id is defined' do
16
- specify do
17
- subject.call env
18
- env[:machine_state_id].should == :not_created
24
+ it_behaves_like 'a proxmox action call'
25
+
26
+ it 'should store the machine state in env[:machine_state_id]' do
27
+ expect(connection).to receive(:get_vm_state).and_return :running
28
+ action.call env
29
+ expect(env[:machine_state_id]).to eq(:running)
19
30
  end
20
- end
21
31
 
22
- context 'when the machine is not created' do
23
- before { env[:machine].id = 'localhost/100' }
24
- specify do
25
- RestClient.should_receive(:get).with('https://your.proxmox.server/api2/json/nodes/localhost/openvz/100/status/current', anything).
26
- and_raise(RestClient::InternalServerError)
27
- subject.call env
28
- env[:machine_state_id].should == :not_created
32
+ it 'should call get_vm_state with the node and vm_id' do
33
+ expect(connection).to receive(:get_vm_state).with vm_id
34
+ action.call env
29
35
  end
30
- end
31
36
 
32
- context 'when the machine is stopped' do
33
- before { env[:machine].id = 'localhost/100' }
34
- specify do
35
- RestClient.should_receive(:get).with('https://your.proxmox.server/api2/json/nodes/localhost/openvz/100/status/current', anything).
36
- and_return({data: {status: 'stopped'}}.to_json)
37
- subject.call env
38
- env[:machine_state_id].should == :stopped
37
+ context 'when no machine id is defined' do
38
+ let(:machine_id) { nil }
39
+ it 'should [:machine_state_id] to :not_created' do
40
+ action.call env
41
+ expect(env[:machine_state_id]).to eq(:not_created)
42
+ end
39
43
  end
40
- end
41
44
 
42
- context 'when the machine is running' do
43
- before { env[:machine].id = 'localhost/100' }
44
- specify do
45
- RestClient.should_receive(:get).with('https://your.proxmox.server/api2/json/nodes/localhost/openvz/100/status/current', anything).
46
- and_return({data: {status: 'running'}}.to_json)
47
- subject.call env
48
- env[:machine_state_id].should == :running
45
+ context 'when the server communication fails' do
46
+ before { allow(connection).to receive(:get_vm_state).and_raise ApiError::ConnectionError }
47
+ it 'should raise an error' do
48
+ expect { action.call env }.to raise_error Errors::CommunicationError
49
+ end
49
50
  end
51
+
50
52
  end
51
53
 
52
54
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+ require 'actions/proxmox_action_shared'
3
+
4
+ module VagrantPlugins::Proxmox
5
+
6
+ describe VagrantPlugins::Proxmox::Action::SelectNode do
7
+
8
+ let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
9
+ let(:connection) { Connection.new 'https://proxmox.example.com/api2/json' }
10
+ let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox),
11
+ proxmox_connection: connection, proxmox_nodes: nodes} }
12
+ let(:nodes) { ['node1', 'node2'] }
13
+
14
+ subject(:action) { described_class.new(-> (_) {}, environment) }
15
+
16
+ describe '#call' do
17
+
18
+ before do
19
+ allow(nodes).to receive(:sample).and_return 'node2'
20
+ end
21
+
22
+ it_behaves_like 'a proxmox action call'
23
+
24
+ it 'randomly selects a node from the list of available nodes' do
25
+ action.call env
26
+ expect(env[:proxmox_selected_node]).to eq('node2')
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -1,35 +1,63 @@
1
1
  require 'spec_helper'
2
2
  require 'actions/proxmox_action_shared'
3
3
 
4
- describe VagrantPlugins::Proxmox::Action::ShutdownVm do
4
+ module VagrantPlugins::Proxmox
5
5
 
6
- let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
- let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox),
8
- proxmox_nodes: [{node: 'localhost'}],
9
- ui: double('ui').as_null_object} }
6
+ describe Action::ShutdownVm do
10
7
 
11
- subject { described_class.new(-> (_) {}, environment) }
8
+ let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
9
+ let(:connection) { Connection.new 'https://proxmox.example.com/api2/json' }
10
+ let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox),
11
+ ui: double('ui').as_null_object,
12
+ proxmox_connection: connection} }
12
13
 
13
- describe '#call' do
14
+ subject(:action) { described_class.new(-> (_) {}, environment) }
14
15
 
15
- before do
16
- env[:machine].id = 'localhost/100'
17
- allow(RestClient).to receive(:post).and_return({data: 'task_id'}.to_json)
18
- allow(RestClient).to receive(:get).and_return({data: {exitstatus: 'OK'}}.to_json)
19
- end
16
+ describe '#call' do
20
17
 
21
- it_behaves_like 'a proxmox action call'
22
- it_behaves_like 'a blocking proxmox action'
18
+ before do
19
+ env[:machine].id = 'localhost/100'
20
+ allow(connection).to receive_messages :shutdown_vm => 'OK'
21
+ end
23
22
 
24
- it 'should send a post request that shuts down the openvz container' do
25
- RestClient.should_receive(:post).with('https://your.proxmox.server/api2/json/nodes/localhost/openvz/100/status/shutdown', nil, anything)
26
- subject.call env
27
- end
23
+ it_behaves_like 'a proxmox action call'
24
+
25
+ it 'should call the shutdown_vm function of connection' do
26
+ expect(connection).to receive(:shutdown_vm).with '100'
27
+ action.call env
28
+ end
29
+
30
+ it 'should print a message to the user interface' do
31
+ expect(env[:ui]).to receive(:info).with 'Shutting down the virtual machine...'
32
+ expect(env[:ui]).to receive(:info).with 'Done!'
33
+ action.call env
34
+ end
35
+
36
+ context 'when the proxmox server responds with an error to the shutdown request' do
37
+
38
+ context 'when the proxmox server replies with an internal server error to the shutdown request' do
39
+ it 'should raise a VMShutdownError' do
40
+ allow(connection).to receive(:shutdown_vm).and_raise ApiError::ServerError
41
+ expect { action.send :call, env }.to raise_error Errors::VMShutdownError
42
+ end
43
+ end
44
+
45
+ context 'when the proxmox server replies with an internal server error to the task status request' do
46
+ it 'should raise a VMShutdownError' do
47
+ allow(connection).to receive(:shutdown_vm).and_raise ApiError::ServerError
48
+ expect { action.send :call, env }.to raise_error Errors::VMShutdownError
49
+ end
50
+ end
51
+
52
+ context 'when the proxmox server does not reply the task status request with OK' do
53
+ it 'should raise a VMShutdownError' do
54
+ allow(connection).to receive_messages :shutdown_vm => 'shutdown vm error'
55
+ expect { action.send :call, env }.to raise_error Errors::VMShutdownError, /shutdown vm error/
56
+ end
57
+ end
58
+
59
+ end
28
60
 
29
- it 'should print a message to the user interface' do
30
- env[:ui].should_receive(:info).with 'Shutting down the virtual machine...'
31
- env[:ui].should_receive(:info).with 'Done!'
32
- subject.call env
33
61
  end
34
62
 
35
63
  end
@@ -1,47 +1,101 @@
1
1
  require 'spec_helper'
2
2
  require 'actions/proxmox_action_shared'
3
3
 
4
- describe VagrantPlugins::Proxmox::Action::StartVm do
4
+ module VagrantPlugins::Proxmox
5
5
 
6
- let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
- let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox),
8
- proxmox_nodes: [{node: 'localhost'}],
9
- ui: double('ui').as_null_object} }
6
+ describe Action::StartVm do
10
7
 
11
- subject { described_class.new(-> (_) {}, environment) }
8
+ let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
9
+ let(:connection) { Connection.new 'https://proxmox.example.com/api2/json' }
10
+ let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox),
11
+ ui: double('ui').as_null_object,
12
+ proxmox_connection: connection} }
13
+ let(:ssh_reachable) { true }
14
+ let(:ssh_timeout) { 60 }
15
+ let(:ssh_status_check_interval) { 5 }
12
16
 
13
- describe '#call' do
17
+ subject(:action) { described_class.new(-> (_) {}, environment) }
14
18
 
15
- before do
16
- env[:machine].id = 'localhost/100'
17
- allow(RestClient).to receive(:post).and_return({data: 'task_id'}.to_json)
18
- allow(RestClient).to receive(:get).and_return({data: {exitstatus: 'OK'}}.to_json)
19
- allow(env[:machine].communicate).to receive(:ready?).and_return true
20
- end
19
+ describe '#call' do
21
20
 
22
- it_behaves_like 'a proxmox action call'
23
- it_behaves_like 'a blocking proxmox action'
21
+ before do
22
+ env[:machine].id = 'localhost/100'
23
+ allow(connection).to receive_messages :start_vm => 'OK'
24
+ allow(env[:machine].communicate).to receive_messages :ready? => ssh_reachable
25
+ end
24
26
 
25
- it 'should send a post request that starts the openvz container' do
26
- RestClient.should_receive(:post).with('https://your.proxmox.server/api2/json/nodes/localhost/openvz/100/status/start', nil, anything)
27
- subject.call env
28
- end
27
+ it_behaves_like 'a proxmox action call'
29
28
 
30
- it 'should print a message to the user interface' do
31
- env[:ui].should_receive(:info).with 'Starting the virtual machine...'
32
- env[:ui].should_receive(:info).with 'Done!'
33
- env[:ui].should_receive(:info).with 'Waiting for SSH connection...'
34
- env[:ui].should_receive(:info).with 'Done!'
35
- subject.call env
36
- end
29
+ it 'should call the start_vm function of connection' do
30
+ expect(connection).to receive(:start_vm).with '100'
31
+ action.call env
32
+ end
37
33
 
38
- it 'should periodically call env[:machine].communicate.ready? to check for ssh access' do
39
- expect(env[:machine].communicate).to receive(:ready?).and_return false
40
- expect(subject).to receive(:sleep).with 1
41
- expect(env[:machine].communicate).to receive(:ready?).and_return true
42
- subject.call env
43
- end
34
+ it 'should print a message to the user interface' do
35
+ expect(env[:ui]).to receive(:info).with 'Starting the virtual machine...'
36
+ expect(env[:ui]).to receive(:info).with 'Done!'
37
+ expect(env[:ui]).to receive(:info).with 'Waiting for SSH connection...'
38
+ expect(env[:ui]).to receive(:info).with 'Done!'
39
+ action.call env
40
+ end
44
41
 
45
- end
42
+ it 'should periodically call env[:machine].communicate.ready? to check for ssh access' do
43
+ expect(env[:machine].communicate).to receive(:ready?).and_return false
44
+ expect(subject).to receive(:sleep).with ssh_status_check_interval
45
+ expect(env[:machine].communicate).to receive(:ready?).and_return true
46
+ action.call env
47
+ end
48
+
49
+ context 'when the proxmox server responds with an error to the start request' do
50
+
51
+ context 'when the proxmox server replies with an internal server error to the start request' do
52
+ it 'should raise a VMStartError' do
53
+ allow(connection).to receive(:start_vm).and_raise ApiError::ServerError
54
+ expect { action.send :call, env }.to raise_error Errors::VMStartError
55
+ end
56
+ end
57
+
58
+ context 'when the proxmox server replies with an internal server error to the task status request' do
59
+ it 'should raise a VMStartError' do
60
+ allow(connection).to receive(:start_vm).and_raise ApiError::ServerError
61
+ expect { action.send :call, env }.to raise_error Errors::VMStartError
62
+ end
63
+ end
64
+
65
+ context 'when the proxmox server does not reply the task status request with OK' do
66
+ it 'should raise a VMStartError' do
67
+ allow(connection).to receive_messages :start_vm => 'start vm error'
68
+ expect { action.send :call, env }.to raise_error Errors::VMStartError, /start vm error/
69
+ end
70
+ end
46
71
 
72
+ end
73
+
74
+ context 'when no ssh connection can be established after startup' do
75
+
76
+ let(:ssh_reachable) { false }
77
+
78
+ before do
79
+ allow(action).to receive(:sleep) { |duration| Timecop.travel(Time.now + duration) }
80
+ Timecop.freeze
81
+ end
82
+
83
+ after do
84
+ Timecop.return
85
+ end
86
+
87
+ it 'should wait the default timeout' do
88
+ begin
89
+ action.call env
90
+ rescue Errors::SSHError
91
+ end
92
+ expect(Time).to have_elapsed ssh_timeout.seconds
93
+ end
94
+
95
+ it 'should raise an ssh error' do
96
+ expect { action.send :call, env }.to raise_error Errors::SSHError, /Unable to establish an ssh connection/
97
+ end
98
+ end
99
+ end
100
+ end
47
101
  end
@@ -1,37 +1,64 @@
1
1
  require 'spec_helper'
2
2
  require 'actions/proxmox_action_shared'
3
3
 
4
- describe VagrantPlugins::Proxmox::Action::StopVm do
4
+ module VagrantPlugins::Proxmox
5
5
 
6
- let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
7
- let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox),
8
- proxmox_nodes: [{node: 'localhost'}],
9
- ui: double('ui').as_null_object} }
6
+ describe Action::StopVm do
10
7
 
11
- subject { described_class.new(-> (_) {}, environment) }
8
+ let(:environment) { Vagrant::Environment.new vagrantfile_name: 'dummy_box/Vagrantfile' }
9
+ let(:connection) { Connection.new 'https://proxmox.example.com/api2/json' }
10
+ let(:env) { {machine: environment.machine(environment.primary_machine_name, :proxmox),
11
+ ui: double('ui').as_null_object, proxmox_connection: connection} }
12
12
 
13
- describe '#call' do
13
+ subject(:action) { described_class.new(-> (_) {}, environment) }
14
14
 
15
- before do
16
- env[:machine].id = 'localhost/100'
17
- allow(RestClient).to receive(:post).and_return({data: 'task_id'}.to_json)
18
- allow(RestClient).to receive(:get).and_return({data: {exitstatus: 'OK'}}.to_json)
19
- end
15
+ describe '#call' do
20
16
 
21
- it_behaves_like 'a proxmox action call'
22
- it_behaves_like 'a blocking proxmox action'
17
+ before do
18
+ env[:machine].id = 'localhost/100'
19
+ allow(connection).to receive_messages :stop_vm => 'OK'
20
+ end
23
21
 
24
- it 'should send a post request that stops the openvz container' do
25
- RestClient.should_receive(:post).with('https://your.proxmox.server/api2/json/nodes/localhost/openvz/100/status/stop', nil, anything)
26
- subject.call env
27
- end
22
+ it_behaves_like 'a proxmox action call'
23
+
24
+ it 'should call the stop_vm function of connection' do
25
+ expect(connection).to receive(:stop_vm).with '100'
26
+ action.call env
27
+ end
28
+
29
+ it 'should print a message to the user interface' do
30
+ expect(env[:ui]).to receive(:info).with 'Stopping the virtual machine...'
31
+ expect(env[:ui]).to receive(:info).with 'Done!'
32
+ action.call env
33
+ end
34
+
35
+ context 'when the proxmox server responds with an error to the stop request' do
36
+
37
+ context 'when the proxmox server replies with an internal server error to the stop request' do
38
+ it 'should raise a VMStopError' do
39
+ allow(connection).to receive(:stop_vm).and_raise ApiError::ServerError
40
+ expect { action.send :call, env }.to raise_error Errors::VMStopError
41
+ end
42
+ end
43
+
44
+ context 'when the proxmox server replies with an internal server error to the task status request' do
45
+ it 'should raise a VMStopError' do
46
+ allow(connection).to receive(:stop_vm).and_raise ApiError::ServerError
47
+ expect { action.send :call, env }.to raise_error Errors::VMStopError
48
+ end
49
+ end
50
+
51
+ context 'when the proxmox server does not reply the task status request with OK' do
52
+ it 'should raise a VMStopError' do
53
+ allow(connection).to receive_messages :stop_vm => 'stop vm error'
54
+ expect { action.send :call, env }.to raise_error Errors::VMStopError, /stop vm error/
55
+ end
56
+ end
57
+
58
+ end
28
59
 
29
- it 'should print a message to the user interface' do
30
- env[:ui].should_receive(:info).with 'Stopping the virtual machine...'
31
- env[:ui].should_receive(:info).with 'Done!'
32
- subject.call env
33
60
  end
34
61
 
35
62
  end
36
63
 
37
- end
64
+ end