From 66e118a92aa480739f62e4675ed80c79ef80619c Mon Sep 17 00:00:00 2001 From: Ben Ford Date: Wed, 19 Aug 2015 08:31:36 -0700 Subject: Add a service_provider fact This returns the default provider Puppet will choose to manage services on this system by instantiating a dummy service resource type and returning the provider chosen. Co-Authored-By: Simon Fraser University --- spec/unit/facter/service_provider_spec.rb | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 spec/unit/facter/service_provider_spec.rb (limited to 'spec/unit/facter/service_provider_spec.rb') diff --git a/spec/unit/facter/service_provider_spec.rb b/spec/unit/facter/service_provider_spec.rb new file mode 100644 index 0000000..ad8a5fc --- /dev/null +++ b/spec/unit/facter/service_provider_spec.rb @@ -0,0 +1,37 @@ +#! /usr/bin/env ruby -S rspec +require 'spec_helper' +require 'puppet/type' +require 'puppet/type/service' + +describe 'service_provider', :type => :fact do + before { Facter.clear } + after { Facter.clear } + + context "macosx" do + it "should return launchd" do + provider = Puppet::Type.type(:service).provider(:launchd) + Puppet::Type.type(:service).stubs(:defaultprovider).returns provider + + expect(Facter.fact(:service_provider).value).to eq('launchd') + end + end + + context "systemd" do + it "should return systemd" do + provider = Puppet::Type.type(:service).provider(:systemd) + Puppet::Type.type(:service).stubs(:defaultprovider).returns provider + + expect(Facter.fact(:service_provider).value).to eq('systemd') + end + end + + context "redhat" do + it "should return redhat" do + provider = Puppet::Type.type(:service).provider(:redhat) + Puppet::Type.type(:service).stubs(:defaultprovider).returns provider + + expect(Facter.fact(:service_provider).value).to eq('redhat') + end + end + +end -- cgit v1.2.3