summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-11-05 13:17:35 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2014-11-08 11:26:07 -0800
commit1b0fddec894dc166de99a61e8243468a1a4c47ee (patch)
treecb74bcc351d30fad96787f14a36a9b843d427ce6
parent550cbad4aea1554159aba59c5c310d5a6180bd60 (diff)
downloadchef-1b0fddec894dc166de99a61e8243468a1a4c47ee.tar.gz
spec fixes
-rw-r--r--lib/chef/platform/provider_priority_map.rb5
-rw-r--r--lib/chef/provider/service/insserv.rb2
-rw-r--r--spec/unit/provider_resolver_spec.rb35
3 files changed, 36 insertions, 6 deletions
diff --git a/lib/chef/platform/provider_priority_map.rb b/lib/chef/platform/provider_priority_map.rb
index ccf6ef0bbe..765dd74859 100644
--- a/lib/chef/platform/provider_priority_map.rb
+++ b/lib/chef/platform/provider_priority_map.rb
@@ -34,9 +34,10 @@ class Chef
], platform_family: "gentoo"
priority :service, [
- # on debian-ish system if an upstart script exists that always wins
- Chef::Provider::Service::Upstart,
+ # we can determine what systemd supports accurately
Chef::Provider::Service::Systemd,
+ # on debian-ish system if an upstart script exists that must win over sysv types
+ Chef::Provider::Service::Upstart,
Chef::Provider::Service::Insserv,
Chef::Provider::Service::Debian,
Chef::Provider::Service::Invokercd,
diff --git a/lib/chef/provider/service/insserv.rb b/lib/chef/provider/service/insserv.rb
index 37901b7802..31965a4bc6 100644
--- a/lib/chef/provider/service/insserv.rb
+++ b/lib/chef/provider/service/insserv.rb
@@ -31,7 +31,7 @@ class Chef
end
def self.supports?(resource, action)
- Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:upstart)
+ Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:initd)
end
def load_current_resource
diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb
index 5be6ebe661..c56207c554 100644
--- a/spec/unit/provider_resolver_spec.rb
+++ b/spec/unit/provider_resolver_spec.rb
@@ -70,6 +70,29 @@ describe Chef::ProviderResolver do
it "when only the SysV init script exists, it returns a Service::Debian provider" do
allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
+ .and_return( [ :initd, :systemd ] )
+ expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
+ end
+
+ it "when both SysV and Upstart scripts exist, it returns a Service::Upstart provider" do
+ allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
+ .and_return( [ :initd, :upstart, :systemd ] )
+ expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
+ end
+
+ it "when only the Upstart script exists, it returns a Service::Upstart provider" do
+ allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
+ .and_return( [ :upstart, :systemd ] )
+ expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
+ end
+
+ it "when both do not exist, it calls the old style provider resolver and returns a Debian Provider" do
+ allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
+ .and_return( [ :systemd ] )
+ expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
+ end
+ it "when only the SysV init script exists, it returns a Service::Debian provider" do
+ allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
.and_return( [ :initd ] )
expect(resolved_provider).to eql(Chef::Provider::Service::Debian)
end
@@ -89,7 +112,7 @@ describe Chef::ProviderResolver do
it "when both do not exist, it calls the old style provider resolver and returns a Debian Provider" do
allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
.and_return( [ ] )
- expect(resolved_provider).to eql(Chef::Provider::Service::Debian)
+ expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
end
end
@@ -234,6 +257,12 @@ describe Chef::ProviderResolver do
.and_return( [ :initd ] )
expect(resolved_provider).to eql(Chef::Provider::Service::Insserv)
end
+
+ it "uses the Service::Insserv Provider when there is no config" do
+ allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
+ .and_return( [ ] )
+ expect(resolved_provider).to eql(Chef::Provider::Service::Insserv)
+ end
end
context "when the user has installed upstart" do
@@ -241,7 +270,7 @@ describe Chef::ProviderResolver do
stub_service_providers(:debian, :invokercd, :insserv, :upstart)
end
- it "when only the SysV init script exists, it returns a Service::Debian provider" do
+ it "when only the SysV init script exists, it returns an Insserv provider" do
allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
.and_return( [ :initd ] )
expect(resolved_provider).to eql(Chef::Provider::Service::Insserv)
@@ -262,7 +291,7 @@ describe Chef::ProviderResolver do
it "when both do not exist, it calls the old style provider resolver and returns a Debian Provider" do
allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
.and_return( [ ] )
- expect(resolved_provider).to eql(Chef::Provider::Service::Insserv)
+ expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
end
end
end