diff options
| author | Nick Lewis <nick@puppetlabs.com> | 2010-10-04 15:23:02 -0700 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2010-11-10 06:24:01 +1100 |
| commit | 4cbceab68f3d84b322d9b78ddb95c34615906bb9 (patch) | |
| tree | a3f2a36066e281f78c86d73a4b903c6b13c5a395 /spec/unit/provider/service | |
| parent | 06c8748cbfed67b2440e11577a52f60c43277217 (diff) | |
| download | puppet-4cbceab68f3d84b322d9b78ddb95c34615906bb9.tar.gz puppet-4cbceab68f3d84b322d9b78ddb95c34615906bb9.tar.xz puppet-4cbceab68f3d84b322d9b78ddb95c34615906bb9.zip | |
(#4573) FreeBSD service provider now supports versions <7 and >8
Running "/etc/rc.d/SERVICE rcvar" outputs different formats for
different versions of FreeBSD. This patch adds support for those
formats, as well as tests.
Based on patches from:
o Joost van Beurden
o Russell Jackson
Paired-With: Matt Robinson
Diffstat (limited to 'spec/unit/provider/service')
| -rw-r--r-- | spec/unit/provider/service/freebsd_spec.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/unit/provider/service/freebsd_spec.rb b/spec/unit/provider/service/freebsd_spec.rb new file mode 100644 index 000000000..0330adbed --- /dev/null +++ b/spec/unit/provider/service/freebsd_spec.rb @@ -0,0 +1,50 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../../spec_helper' + +provider_class = Puppet::Type.type(:service).provider(:freebsd) + +describe provider_class do + before :each do + @provider = provider_class.new + @provider.stubs(:initscript) + end + + it "should correctly parse rcvar for FreeBSD < 7" do + @provider.stubs(:execute).returns <<OUTPUT +# ntpd +$ntpd_enable=YES +OUTPUT + @provider.rcvar.should == ['# ntpd', 'ntpd_enable=YES'] + end + + it "should correctly parse rcvar for FreeBSD 7 to 8" do + @provider.stubs(:execute).returns <<OUTPUT +# ntpd +ntpd_enable=YES +OUTPUT + @provider.rcvar.should == ['# ntpd', 'ntpd_enable=YES'] + end + + it "should correctly parse rcvar for FreeBSD >= 8.1" do + @provider.stubs(:execute).returns <<OUTPUT +# ntpd +# +ntpd_enable="YES" +# (default: "") +OUTPUT + @provider.rcvar.should == ['# ntpd', 'ntpd_enable="YES"', '# (default: "")'] + end + + it "should find the right rcvar_value for FreeBSD < 7" do + @provider.stubs(:rcvar).returns(['# ntpd', 'ntpd_enable=YES']) + + @provider.rcvar_value.should == "YES" + end + + it "should find the right rcvar_value for FreeBSD >= 7" do + @provider.stubs(:rcvar).returns(['# ntpd', 'ntpd_enable="YES"', '# (default: "")']) + + @provider.rcvar_value.should == "YES" + end +end |
