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.
@@ -1,73 +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_zone_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::GoogleZoneList 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!)
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 "#query_resource" do
56
- it "uses the service to list zones" do
57
- expect(service).to receive(:list_zones).and_return("zones")
58
- expect(command.query_resource).to eq("zones")
59
- end
60
- end
61
-
62
- describe "#format_status_value" do
63
- it "returns green when the status is up" do
64
- expect(command.ui).to receive(:color).with("up", :green)
65
- command.format_status_value("up")
66
- end
67
-
68
- it "returns red when the status is stopped" do
69
- expect(command.ui).to receive(:color).with("stopped", :red)
70
- command.format_status_value("stopped")
71
- end
72
- end
73
- end