summaryrefslogtreecommitdiff
path: root/spec/unit/provider/service
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-07-05 13:41:00 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-07-05 13:41:00 -0700
commit174a2748b54a5dbd746005e2aead59221b80f2b9 (patch)
tree55e4bacca96b540526f3c19a00d666e68610ea6e /spec/unit/provider/service
parent3b10f9ca503dcbce747241281b9151d3d010f9ef (diff)
downloadchef-174a2748b54a5dbd746005e2aead59221b80f2b9.tar.gz
fix 4 cops
- Layout/MultilineMethodCallBraceLayout - Layout/ClosingParenthesisIndentation - Layout/IndentFirstArgument EnforcedStyle: consistent - Layout/BlockEndNewline the first of these autocorrected to horrible looking code which exposed that we really needed the other three as well, which also cleaned up a bunch of other terrible looking code. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/unit/provider/service')
-rw-r--r--spec/unit/provider/service/debian_service_spec.rb3
-rw-r--r--spec/unit/provider/service/freebsd_service_spec.rb12
-rw-r--r--spec/unit/provider/service/openbsd_service_spec.rb12
-rw-r--r--spec/unit/provider/service/windows_spec.rb74
4 files changed, 64 insertions, 37 deletions
diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb
index 626abb10f7..5f89605b2e 100644
--- a/spec/unit/provider/service/debian_service_spec.rb
+++ b/spec/unit/provider/service/debian_service_spec.rb
@@ -89,7 +89,8 @@ describe Chef::Provider::Service::Debian do
"0" => [:stop, "20"],
"1" => [:stop, "20"],
"6" => [:stop, "20"],
- })
+ }
+ )
end
end
diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb
index 3fb7a0de87..4392786edc 100644
--- a/spec/unit/provider/service/freebsd_service_spec.rb
+++ b/spec/unit/provider/service/freebsd_service_spec.rb
@@ -261,7 +261,8 @@ describe Chef::Provider::Service::Freebsd do
[
%Q{thing_#{new_resource.service_name}_enable="YES"},
%Q{#{new_resource.service_name}_enable="NO"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (false)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be false
@@ -273,7 +274,8 @@ describe Chef::Provider::Service::Freebsd do
[
%Q{#{new_resource.service_name}_thing_enable="YES"},
%Q{#{new_resource.service_name}_enable="NO"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (false)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be false
@@ -285,7 +287,8 @@ describe Chef::Provider::Service::Freebsd do
[
%Q{thing_#{new_resource.service_name}_enable="NO"},
%Q{#{new_resource.service_name}_enable="YES"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (true)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be true
@@ -297,7 +300,8 @@ describe Chef::Provider::Service::Freebsd do
[
%Q{#{new_resource.service_name}_thing_enable="NO"},
%Q{#{new_resource.service_name}_enable="YES"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (true)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be true
diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb
index 9cb8a2b5dc..dfa491fc38 100644
--- a/spec/unit/provider/service/openbsd_service_spec.rb
+++ b/spec/unit/provider/service/openbsd_service_spec.rb
@@ -178,7 +178,8 @@ describe Chef::Provider::Service::Openbsd do
[
%Q{thing_#{provider.builtin_service_enable_variable_name}="YES"},
%Q{#{provider.builtin_service_enable_variable_name}="NO"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (false)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be false
@@ -190,7 +191,8 @@ describe Chef::Provider::Service::Openbsd do
[
%Q{#{provider.builtin_service_enable_variable_name}_thing="YES"},
(provider.builtin_service_enable_variable_name).to_s,
- ] end
+ ]
+ end
it "sets enabled based on the exact match (false)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be false
@@ -202,7 +204,8 @@ describe Chef::Provider::Service::Openbsd do
[
%Q{thing_#{provider.builtin_service_enable_variable_name}="NO"},
%Q{#{provider.builtin_service_enable_variable_name}="YES"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (true)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be true
@@ -214,7 +217,8 @@ describe Chef::Provider::Service::Openbsd do
[
%Q{#{provider.builtin_service_enable_variable_name}_thing="NO"},
%Q{#{provider.builtin_service_enable_variable_name}="YES"},
- ] end
+ ]
+ end
it "sets enabled based on the exact match (true)" do
provider.determine_enabled_status!
expect(current_resource.enabled).to be true
diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb
index 8cda32973e..860c0b1d6a 100644
--- a/spec/unit/provider/service/windows_spec.rb
+++ b/spec/unit/provider/service/windows_spec.rb
@@ -41,8 +41,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
tag_id: 0,
dependencies: ["Winmgmt"],
service_start_name: "LocalSystem",
- display_name: "Chef Client Service"
- )
+ display_name: "Chef Client Service")
end
# Actual response from Win32::Service.services
@@ -73,8 +72,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
command: nil,
num_actions: 0,
actions: nil,
- delayed_start: 1
- )
+ delayed_start: 1)
end
let(:provider) do
@@ -98,7 +96,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
allow(Win32::Service).to receive(:start).with(any_args).and_return(Win32::Service)
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", current_state: "running"))
+ double("StatusStruct", current_state: "running")
+ )
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name)
.and_return(chef_service_config_info)
@@ -155,8 +154,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
tag_id: 0,
dependencies: %w{NSI Tdx Afd},
service_start_name: 'NT Authority\\LocalService',
- display_name: "DHCP Client"
- ))
+ display_name: "DHCP Client")
+ )
end
context "startup_type is neither :automatic or :disabled" do
@@ -171,8 +170,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
tag_id: 0,
dependencies: %w{NSI Tdx Afd},
service_start_name: 'NT Authority\\LocalService',
- display_name: "DHCP Client"
- ))
+ display_name: "DHCP Client")
+ )
end
it "does not set the current resources enabled" do
@@ -473,7 +472,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
before(:each) do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
double("StatusStruct", current_state: "stopped"),
- double("StatusStruct", current_state: "running"))
+ double("StatusStruct", current_state: "running")
+ )
end
context "run_as_user user is specified" do
@@ -555,7 +555,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "does nothing if the service is running" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", current_state: "running"))
+ double("StatusStruct", current_state: "running")
+ )
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
provider.start_service
@@ -565,7 +566,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
context "service is paused" do
before do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", current_state: "paused"))
+ double("StatusStruct", current_state: "paused")
+ )
provider.load_current_resource
end
@@ -590,7 +592,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
double("StatusStruct", current_state: "start pending"),
double("StatusStruct", current_state: "start pending"),
- double("StatusStruct", current_state: "running"))
+ double("StatusStruct", current_state: "running")
+ )
provider.load_current_resource
end
@@ -614,7 +617,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
context "service is in stop_pending" do
before do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", current_state: "stop pending"))
+ double("StatusStruct", current_state: "stop pending")
+ )
provider.load_current_resource
end
@@ -665,7 +669,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
before(:each) do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
double("StatusStruct", current_state: "running"),
- double("StatusStruct", current_state: "stopped"))
+ double("StatusStruct", current_state: "stopped")
+ )
end
it "calls the stop command if one is specified" do
@@ -690,7 +695,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "does nothing if the service is stopped" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", current_state: "stopped"))
+ double("StatusStruct", current_state: "stopped")
+ )
provider.load_current_resource
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
provider.stop_service
@@ -699,7 +705,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "raises an error if the service is paused" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", current_state: "paused"))
+ double("StatusStruct", current_state: "paused")
+ )
provider.load_current_resource
expect(Win32::Service).not_to receive(:start).with(new_resource.service_name)
expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service )
@@ -710,7 +717,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
double("StatusStruct", current_state: "stop pending"),
double("StatusStruct", current_state: "stop pending"),
- double("StatusStruct", current_state: "stopped"))
+ double("StatusStruct", current_state: "stopped")
+ )
provider.load_current_resource
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
provider.stop_service
@@ -719,7 +727,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "fails if the service is in start_pending" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", current_state: "start pending"))
+ double("StatusStruct", current_state: "start pending")
+ )
provider.load_current_resource
expect(Win32::Service).not_to receive(:stop).with(new_resource.service_name)
expect { provider.stop_service }.to raise_error( Chef::Exceptions::Service )
@@ -728,7 +737,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
it "passes custom timeout to the stop command if provided" do
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
- double("StatusStruct", current_state: "running"))
+ double("StatusStruct", current_state: "running")
+ )
new_resource.timeout 1
expect(Win32::Service).to receive(:stop).with(new_resource.service_name)
Timeout.timeout(2) do
@@ -753,7 +763,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
double("StatusStruct", current_state: "running"),
double("StatusStruct", current_state: "stopped"),
double("StatusStruct", current_state: "stopped"),
- double("StatusStruct", current_state: "running"))
+ double("StatusStruct", current_state: "running")
+ )
expect(Win32::Service).to receive(:stop).with(new_resource.service_name)
expect(Win32::Service).to receive(:start).with(new_resource.service_name)
provider.restart_service
@@ -764,7 +775,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
allow(Win32::Service).to receive(:status).with(new_resource.service_name).and_return(
double("StatusStruct", current_state: "stopped"),
double("StatusStruct", current_state: "stopped"),
- double("StatusStruct", current_state: "running"))
+ double("StatusStruct", current_state: "running")
+ )
expect(Win32::Service).to receive(:start).with(new_resource.service_name)
provider.restart_service
expect(new_resource).to be_updated_by_last_action
@@ -783,7 +795,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "enable_service" do
before(:each) do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", start_type: "disabled"))
+ double("ConfigStruct", start_type: "disabled")
+ )
end
it "enables service" do
@@ -803,14 +816,16 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "action_enable" do
it "does nothing if the service is enabled" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", start_type: "auto start"))
+ double("ConfigStruct", start_type: "auto start")
+ )
expect(provider).not_to receive(:enable_service)
provider.action_enable
end
it "enables the service if it is not set to automatic start" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", start_type: "disabled"))
+ double("ConfigStruct", start_type: "disabled")
+ )
expect(provider).to receive(:enable_service)
provider.action_enable
end
@@ -819,14 +834,16 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "action_disable" do
it "does nothing if the service is disabled" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", start_type: "disabled"))
+ double("ConfigStruct", start_type: "disabled")
+ )
expect(provider).not_to receive(:disable_service)
provider.action_disable
end
it "disables the service if it is not set to disabled" do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", start_type: "auto start"))
+ double("ConfigStruct", start_type: "auto start")
+ )
expect(provider).to receive(:disable_service)
provider.action_disable
end
@@ -835,7 +852,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource", :windows_onl
describe Chef::Provider::Service::Windows, "disable_service" do
before(:each) do
allow(Win32::Service).to receive(:config_info).with(new_resource.service_name).and_return(
- double("ConfigStruct", start_type: "auto start"))
+ double("ConfigStruct", start_type: "auto start")
+ )
end
it "disables service" do