knife-google 3.3.6 → 3.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/knife-google/version.rb +1 -1
- metadata +2 -33
- data/.expeditor/config.yml +0 -41
- data/.expeditor/update_version.sh +0 -12
- data/.github/CODEOWNERS +0 -4
- data/.github/ISSUE_TEMPLATE.md +0 -21
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -14
- data/.gitignore +0 -26
- data/.rspec +0 -3
- data/.travis.yml +0 -27
- data/CHANGELOG.md +0 -252
- data/Gemfile +0 -30
- data/README.md +0 -305
- data/RELEASE_NOTES.md +0 -18
- data/Rakefile +0 -35
- data/TESTING.md +0 -48
- data/VERSION +0 -1
- data/knife-google.gemspec +0 -25
- data/spec/cloud/google_service_helpers_spec.rb +0 -119
- data/spec/cloud/google_service_spec.rb +0 -1021
- data/spec/google_disk_create_spec.rb +0 -86
- data/spec/google_disk_delete_spec.rb +0 -78
- data/spec/google_disk_list_spec.rb +0 -107
- data/spec/google_project_quotas_spec.rb +0 -77
- data/spec/google_region_list_spec.rb +0 -79
- data/spec/google_region_quotas_spec.rb +0 -122
- data/spec/google_server_create_spec.rb +0 -243
- data/spec/google_server_delete_spec.rb +0 -53
- data/spec/google_server_list_spec.rb +0 -91
- data/spec/google_server_show_spec.rb +0 -74
- data/spec/google_zone_list_spec.rb +0 -73
@@ -1,243 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Chef Partner Engineering (<partnereng@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2016 Chef Software, Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
require "spec_helper"
|
21
|
-
require "chef/knife/google_server_create"
|
22
|
-
require "support/shared_examples_for_command"
|
23
|
-
require "gcewinpass"
|
24
|
-
|
25
|
-
class Tester
|
26
|
-
include Chef::Knife::Cloud::GoogleServiceHelpers
|
27
|
-
end
|
28
|
-
|
29
|
-
describe Chef::Knife::Cloud::GoogleServerCreate do
|
30
|
-
let(:tester) { Tester.new }
|
31
|
-
let(:command) { described_class.new(["test_instance"]) }
|
32
|
-
let(:service) { double("service") }
|
33
|
-
let(:server) { double("server") }
|
34
|
-
|
35
|
-
before do
|
36
|
-
allow(command).to receive(:service).and_return(service)
|
37
|
-
allow(command).to receive(:server).and_return(server)
|
38
|
-
end
|
39
|
-
|
40
|
-
it_behaves_like Chef::Knife::Cloud::Command, described_class.new
|
41
|
-
|
42
|
-
describe "#validate_params!" do
|
43
|
-
before do
|
44
|
-
allow(command).to receive(:check_for_missing_config_values!)
|
45
|
-
allow(command).to receive(:valid_disk_size?).and_return(true)
|
46
|
-
allow(command).to receive(:boot_disk_size)
|
47
|
-
allow(command).to receive(:locate_config_value).with(:bootstrap_protocol).and_return("ssh")
|
48
|
-
allow(command).to receive(:locate_config_value).with(:identity_file).and_return("/path/to/file")
|
49
|
-
allow(command).to receive(:locate_config_value).with(:auto_migrate)
|
50
|
-
allow(command).to receive(:locate_config_value).with(:auto_restart)
|
51
|
-
allow(command).to receive(:locate_config_value).with(:chef_node_name)
|
52
|
-
allow(command).to receive(:locate_config_value).with(:chef_node_name_prefix)
|
53
|
-
allow(command).to receive(:preemptible?).and_return(false)
|
54
|
-
end
|
55
|
-
|
56
|
-
context "when no instance name has been provided" do
|
57
|
-
let(:command) { described_class.new }
|
58
|
-
|
59
|
-
it "raises an exception" do
|
60
|
-
expect { command.validate_params! }.to raise_error(RuntimeError, "You must supply an instance name.")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
it "checks for missing config values" do
|
65
|
-
expect(command).to receive(:check_for_missing_config_values!).with(:gce_zone, :machine_type, :image, :boot_disk_size, :network)
|
66
|
-
|
67
|
-
command.validate_params!
|
68
|
-
end
|
69
|
-
|
70
|
-
it "raises an exception if the boot disk size is not valid" do
|
71
|
-
expect(command).to receive(:valid_disk_size?).and_return(false)
|
72
|
-
expect { command.validate_params! }.to raise_error(RuntimeError)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "raises an exception if the gce_project is missing" do
|
76
|
-
ui = double("ui")
|
77
|
-
expect(tester).to receive(:ui).and_return(ui)
|
78
|
-
expect(tester).to receive(:locate_config_value).with(:gce_project).and_return(nil)
|
79
|
-
expect(ui).to receive(:error).with("The following required parameters are missing: gce_project")
|
80
|
-
expect { tester.check_for_missing_config_values! }.to raise_error(RuntimeError)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "raises an exception if bootstrap is WinRM but no gcloud user email as supplied" do
|
84
|
-
expect(command).to receive(:locate_config_value).with(:bootstrap_protocol).and_return("winrm")
|
85
|
-
expect(command).to receive(:locate_config_value).with(:gce_email).and_return(nil)
|
86
|
-
expect { command.validate_params! }.to raise_error(RuntimeError)
|
87
|
-
end
|
88
|
-
|
89
|
-
it "prints a warning if auto-migrate is true for a preemptible instance" do
|
90
|
-
allow(command).to receive(:preemptible?).and_return(true)
|
91
|
-
allow(command).to receive(:locate_config_value).with(:auto_migrate).and_return(true)
|
92
|
-
expect(command.ui).to receive(:warn).with("Auto-migrate disabled for preemptible instance")
|
93
|
-
command.validate_params!
|
94
|
-
end
|
95
|
-
|
96
|
-
it "prints a warning if auto-restart is true for a preemptible instance" do
|
97
|
-
allow(command).to receive(:preemptible?).and_return(true)
|
98
|
-
allow(command).to receive(:locate_config_value).with(:auto_restart).and_return(true)
|
99
|
-
expect(command.ui).to receive(:warn).with("Auto-restart disabled for preemptible instance")
|
100
|
-
command.validate_params!
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe "#before_bootstrap" do
|
105
|
-
before do
|
106
|
-
allow(command).to receive(:ip_address_for_bootstrap)
|
107
|
-
allow(command).to receive(:locate_config_value)
|
108
|
-
end
|
109
|
-
|
110
|
-
it "sets the node name to what the user provided if a name was provided" do
|
111
|
-
expect(command).to receive(:locate_config_value).with(:chef_node_name).at_least(:once).and_return("my-node")
|
112
|
-
command.before_bootstrap
|
113
|
-
|
114
|
-
expect(command.config[:chef_node_name]).to eq("my-node")
|
115
|
-
end
|
116
|
-
|
117
|
-
it "sets the node name to the instance name if a node name was not provided" do
|
118
|
-
expect(command).to receive(:locate_config_value).with(:chef_node_name).at_least(:once).and_return(nil)
|
119
|
-
expect(command).to receive(:instance_name).and_return("my-instance")
|
120
|
-
command.before_bootstrap
|
121
|
-
|
122
|
-
expect(command.config[:chef_node_name]).to eq("my-instance")
|
123
|
-
end
|
124
|
-
|
125
|
-
it "sets the bootstrap IP" do
|
126
|
-
expect(command).to receive(:ip_address_for_bootstrap).and_return("1.2.3.4")
|
127
|
-
command.before_bootstrap
|
128
|
-
|
129
|
-
expect(command.config[:bootstrap_ip_address]).to eq("1.2.3.4")
|
130
|
-
end
|
131
|
-
|
132
|
-
it "sets the winrm password if winrm is used" do
|
133
|
-
allow(command.ui).to receive(:msg)
|
134
|
-
expect(command).to receive(:locate_config_value).with(:bootstrap_protocol).at_least(:once).and_return("winrm")
|
135
|
-
expect(command).to receive(:reset_windows_password).and_return("new_password")
|
136
|
-
command.before_bootstrap
|
137
|
-
|
138
|
-
expect(command.config[:winrm_password]).to eq("new_password")
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe "#get_node_name" do
|
143
|
-
it "overrides the original method to return nil" do
|
144
|
-
expect(command.get_node_name("name", "prefix")).to eq(nil)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
describe "#project" do
|
149
|
-
it "returns the project from the config" do
|
150
|
-
expect(command).to receive(:locate_config_value).with(:gce_project).and_return("test_project")
|
151
|
-
expect(command.project).to eq("test_project")
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
describe "#zone" do
|
156
|
-
it "returns the zone from the config" do
|
157
|
-
expect(command).to receive(:locate_config_value).with(:gce_zone).and_return("test_zone")
|
158
|
-
expect(command.zone).to eq("test_zone")
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe "#email" do
|
163
|
-
it "returns the email from the config" do
|
164
|
-
expect(command).to receive(:locate_config_value).with(:gce_email).and_return("test_email")
|
165
|
-
expect(command.email).to eq("test_email")
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
describe "#preemptible?" do
|
170
|
-
it "returns the preemptible setting from the config" do
|
171
|
-
expect(command).to receive(:locate_config_value).with(:preemptible).and_return("test_preempt")
|
172
|
-
expect(command.preemptible?).to eq("test_preempt")
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
describe "#auto_migrate?" do
|
177
|
-
it "returns false if the instance is preemptible" do
|
178
|
-
expect(command).to receive(:preemptible?).and_return(true)
|
179
|
-
expect(command.auto_migrate?).to eq(false)
|
180
|
-
end
|
181
|
-
|
182
|
-
it "returns the setting from the config if preemptible is false" do
|
183
|
-
expect(command).to receive(:preemptible?).and_return(false)
|
184
|
-
expect(command).to receive(:locate_config_value).with(:auto_migrate).and_return("test_migrate")
|
185
|
-
expect(command.auto_migrate?).to eq("test_migrate")
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
describe "#auto_restart?" do
|
190
|
-
it "returns false if the instance is preemptible" do
|
191
|
-
expect(command).to receive(:preemptible?).and_return(true)
|
192
|
-
expect(command.auto_restart?).to eq(false)
|
193
|
-
end
|
194
|
-
|
195
|
-
it "returns the setting from the config if preemptible is false" do
|
196
|
-
expect(command).to receive(:preemptible?).and_return(false)
|
197
|
-
expect(command).to receive(:locate_config_value).with(:auto_restart).and_return("test_restart")
|
198
|
-
expect(command.auto_restart?).to eq("test_restart")
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
describe "#ip_address_for_bootstrap" do
|
203
|
-
it "returns the public IP by default" do
|
204
|
-
expect(command).to receive(:locate_config_value).with(:use_private_ip).and_return(false)
|
205
|
-
expect(command).to receive(:public_ip_for).and_return("1.2.3.4")
|
206
|
-
expect(command.ip_address_for_bootstrap).to eq("1.2.3.4")
|
207
|
-
end
|
208
|
-
|
209
|
-
it "returns the private IP if requested by the user" do
|
210
|
-
expect(command).to receive(:locate_config_value).with(:use_private_ip).and_return(true)
|
211
|
-
expect(command).to receive(:private_ip_for).and_return("4.3.2.1")
|
212
|
-
expect(command.ip_address_for_bootstrap).to eq("4.3.2.1")
|
213
|
-
end
|
214
|
-
|
215
|
-
it "raises an exception if an IP cannot be found" do
|
216
|
-
expect(command).to receive(:locate_config_value).with(:use_private_ip).and_return(false)
|
217
|
-
expect(command).to receive(:public_ip_for).and_return("unknown")
|
218
|
-
expect { command.ip_address_for_bootstrap }.to raise_error(RuntimeError)
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
describe "#metadata" do
|
223
|
-
it "returns a hash of metadata" do
|
224
|
-
expect(command).to receive(:locate_config_value).with(:metadata).and_return(["key1=value1", "key2=value2"])
|
225
|
-
expect(command.metadata).to eq({ "key1" => "value1", "key2" => "value2" })
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
describe "#boot_disk_size" do
|
230
|
-
it "returns the disk size as an integer" do
|
231
|
-
expect(command).to receive(:locate_config_value).with(:boot_disk_size).and_return("20")
|
232
|
-
expect(command.boot_disk_size).to eq(20)
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
describe "#reset_windows_password" do
|
237
|
-
it "returns the password from the gcewinpass instance" do
|
238
|
-
winpass = double("winpass", new_password: "my_password")
|
239
|
-
expect(GoogleComputeWindowsPassword).to receive(:new).and_return(winpass)
|
240
|
-
expect(command.reset_windows_password).to eq("my_password")
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Chef Partner Engineering (<partnereng@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2016 Chef Software, Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
require "spec_helper"
|
21
|
-
require "chef/knife/google_server_delete"
|
22
|
-
require "support/shared_examples_for_serverdeletecommand"
|
23
|
-
|
24
|
-
class Tester
|
25
|
-
include Chef::Knife::Cloud::GoogleServiceHelpers
|
26
|
-
end
|
27
|
-
|
28
|
-
describe Chef::Knife::Cloud::GoogleServerDelete do
|
29
|
-
let(:tester) { Tester.new }
|
30
|
-
let(:command) { described_class.new(["test_instance"]) }
|
31
|
-
let(:service) { double("service") }
|
32
|
-
|
33
|
-
before do
|
34
|
-
allow(command).to receive(:service).and_return(service)
|
35
|
-
end
|
36
|
-
|
37
|
-
it_behaves_like Chef::Knife::Cloud::ServerDeleteCommand, described_class.new(["test_instance"])
|
38
|
-
|
39
|
-
describe "#validate_params!" do
|
40
|
-
it "checks for missing config values" do
|
41
|
-
expect(command).to receive(:check_for_missing_config_values!)
|
42
|
-
command.validate_params!
|
43
|
-
end
|
44
|
-
|
45
|
-
it "raises an exception if the gce_project is missing" do
|
46
|
-
ui = double("ui")
|
47
|
-
expect(tester).to receive(:ui).and_return(ui)
|
48
|
-
expect(tester).to receive(:locate_config_value).with(:gce_project).and_return(nil)
|
49
|
-
expect(ui).to receive(:error).with("The following required parameters are missing: gce_project")
|
50
|
-
expect { tester.check_for_missing_config_values! }.to raise_error(RuntimeError)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Chef Partner Engineering (<partnereng@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2016 Chef Software, Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
require "spec_helper"
|
21
|
-
require "chef/knife/google_server_list"
|
22
|
-
require "support/shared_examples_for_command"
|
23
|
-
|
24
|
-
class Tester
|
25
|
-
include Chef::Knife::Cloud::GoogleServiceHelpers
|
26
|
-
end
|
27
|
-
|
28
|
-
describe Chef::Knife::Cloud::GoogleServerList do
|
29
|
-
let(:tester) { Tester.new }
|
30
|
-
let(:command) { described_class.new }
|
31
|
-
let(:service) { double("service") }
|
32
|
-
|
33
|
-
before do
|
34
|
-
allow(command).to receive(:service).and_return(service)
|
35
|
-
end
|
36
|
-
|
37
|
-
it_behaves_like Chef::Knife::Cloud::Command, described_class.new
|
38
|
-
|
39
|
-
describe "#validate_params!" do
|
40
|
-
it "checks for missing config values" do
|
41
|
-
expect(command).to receive(:check_for_missing_config_values!).with(:gce_zone)
|
42
|
-
|
43
|
-
command.validate_params!
|
44
|
-
end
|
45
|
-
|
46
|
-
it "raises an exception if the gce_project is missing" do
|
47
|
-
ui = double("ui")
|
48
|
-
expect(tester).to receive(:ui).and_return(ui)
|
49
|
-
expect(tester).to receive(:locate_config_value).with(:gce_project).and_return(nil)
|
50
|
-
expect(ui).to receive(:error).with("The following required parameters are missing: gce_project")
|
51
|
-
expect { tester.check_for_missing_config_values! }.to raise_error(RuntimeError)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "#format_status_value" do
|
56
|
-
it "returns green when the status is ready" do
|
57
|
-
expect(command.ui).to receive(:color).with("ready", :green)
|
58
|
-
command.format_status_value("ready")
|
59
|
-
end
|
60
|
-
|
61
|
-
it "returns red when the status is stopped" do
|
62
|
-
expect(command.ui).to receive(:color).with("stopped", :red)
|
63
|
-
command.format_status_value("stopped")
|
64
|
-
end
|
65
|
-
|
66
|
-
it "returns red when the status is stopping" do
|
67
|
-
expect(command.ui).to receive(:color).with("stopping", :red)
|
68
|
-
command.format_status_value("stopping")
|
69
|
-
end
|
70
|
-
|
71
|
-
it "returns red when the status is terminated" do
|
72
|
-
expect(command.ui).to receive(:color).with("terminated", :red)
|
73
|
-
command.format_status_value("terminated")
|
74
|
-
end
|
75
|
-
|
76
|
-
it "returns yellow when the status is requested" do
|
77
|
-
expect(command.ui).to receive(:color).with("requested", :yellow)
|
78
|
-
command.format_status_value("requested")
|
79
|
-
end
|
80
|
-
|
81
|
-
it "returns yellow when the status is provisioning" do
|
82
|
-
expect(command.ui).to receive(:color).with("provisioning", :yellow)
|
83
|
-
command.format_status_value("provisioning")
|
84
|
-
end
|
85
|
-
|
86
|
-
it "returns yellow when the status is staging" do
|
87
|
-
expect(command.ui).to receive(:color).with("staging", :yellow)
|
88
|
-
command.format_status_value("staging")
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Chef Partner Engineering (<partnereng@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2016 Chef Software, Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
require "spec_helper"
|
21
|
-
require "chef/knife/google_server_show"
|
22
|
-
require "support/shared_examples_for_command"
|
23
|
-
|
24
|
-
class Tester
|
25
|
-
include Chef::Knife::Cloud::GoogleServiceHelpers
|
26
|
-
end
|
27
|
-
|
28
|
-
describe Chef::Knife::Cloud::GoogleServerShow do
|
29
|
-
let(:tester) { Tester.new }
|
30
|
-
let(:command) { described_class.new(["test_instance"]) }
|
31
|
-
let(:service) { double("service") }
|
32
|
-
|
33
|
-
before do
|
34
|
-
allow(command).to receive(:service).and_return(service)
|
35
|
-
end
|
36
|
-
|
37
|
-
it_behaves_like Chef::Knife::Cloud::Command, described_class.new
|
38
|
-
|
39
|
-
describe "#validate_params!" do
|
40
|
-
before do
|
41
|
-
allow(command).to receive(:check_for_missing_config_values!)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "checks for missing config values" do
|
45
|
-
expect(command).to receive(:check_for_missing_config_values!).with(:gce_zone)
|
46
|
-
|
47
|
-
command.validate_params!
|
48
|
-
end
|
49
|
-
|
50
|
-
it "raises an exception if the gce_project is missing" do
|
51
|
-
ui = double("ui")
|
52
|
-
expect(tester).to receive(:ui).and_return(ui)
|
53
|
-
expect(tester).to receive(:locate_config_value).with(:gce_project).and_return(nil)
|
54
|
-
expect(ui).to receive(:error).with("The following required parameters are missing: gce_project")
|
55
|
-
expect { tester.check_for_missing_config_values! }.to raise_error(RuntimeError)
|
56
|
-
end
|
57
|
-
|
58
|
-
context "when no server name is provided" do
|
59
|
-
let(:command) { described_class.new }
|
60
|
-
|
61
|
-
it "raises an exception" do
|
62
|
-
expect { command.validate_params! }.to raise_error(RuntimeError, "You must supply an instance name to display")
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context "when more than one server name is provided" do
|
67
|
-
let(:command) { described_class.new(%w{server1 server2}) }
|
68
|
-
|
69
|
-
it "raises an exception" do
|
70
|
-
expect { command.validate_params! }.to raise_error(RuntimeError, "You may only supply one instance name")
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|