blob: 8ef5fee78f992ddd391c1070404346daca6040b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#! /usr/bin/env ruby
require '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 correctly parse rcvar for DragonFly BSD" do
@provider.stubs(:execute).returns <<OUTPUT
# ntpd
$ntpd=YES
OUTPUT
@provider.rcvar.should == ['# ntpd', 'ntpd=YES']
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
it "should find the right rcvar_name" do
@provider.stubs(:rcvar).returns(['# ntpd', 'ntpd_enable="YES"'])
@provider.rcvar_name.should == "ntpd"
end
it "should enable only the selected service" do
Puppet::FileSystem.stubs(:exist?).with('/etc/rc.conf').returns(true)
File.stubs(:read).with('/etc/rc.conf').returns("openntpd_enable=\"NO\"\nntpd_enable=\"NO\"\n")
fh = stub 'fh'
File.stubs(:open).with('/etc/rc.conf', File::WRONLY).yields(fh)
fh.expects(:<<).with("openntpd_enable=\"NO\"\nntpd_enable=\"YES\"\n")
Puppet::FileSystem.stubs(:exist?).with('/etc/rc.conf.local').returns(false)
Puppet::FileSystem.stubs(:exist?).with('/etc/rc.conf.d/ntpd').returns(false)
@provider.rc_replace('ntpd', 'ntpd', 'YES')
end
end
|