blob: 9ce03f6f01f0a8469512b82d96889b96cfe1ee13 (
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/provider/mount'
describe Puppet::Provider::Mount do
before :each do
@mounter = Object.new
@mounter.extend(Puppet::Provider::Mount)
@name = "/"
@resource = stub 'resource'
@resource.stubs(:[]).with(:name).returns(@name)
@mounter.stubs(:resource).returns(@resource)
end
describe Puppet::Provider::Mount, " when mounting" do
it "should use the 'mountcmd' method to mount" do
@mounter.stubs(:options).returns(nil)
@mounter.expects(:mountcmd)
@mounter.mount
end
it "should flush before mounting if a flush method exists" do
@mounter.meta_def(:flush) { }
@mounter.expects(:flush)
@mounter.stubs(:mountcmd)
@mounter.stubs(:options).returns(nil)
@mounter.mount
end
it "should add the options following '-o' if they exist and are not set to :absent" do
@mounter.stubs(:options).returns("ro")
@mounter.expects(:mountcmd).with { |*ary| ary[0] == "-o" and ary[1] == "ro" }
@mounter.mount
end
it "should specify the filesystem name to the mount command" do
@mounter.stubs(:options).returns(nil)
@mounter.expects(:mountcmd).with { |*ary| ary[-1] == @name }
@mounter.mount
end
end
describe Puppet::Provider::Mount, " when remounting" do
it "should use '-o remount' if the resource specifies it supports remounting" do
@mounter.stubs(:info)
@resource.stubs(:[]).with(:remounts).returns(:true)
@mounter.expects(:mountcmd).with("-o", "remount", @name)
@mounter.remount
end
it "should unmount and mount if the resource does not specify it supports remounting" do
@mounter.stubs(:info)
@resource.stubs(:[]).with(:remounts).returns(false)
@mounter.expects(:unmount)
@mounter.expects(:mount)
@mounter.remount
end
it "should log that it is remounting" do
@resource.stubs(:[]).with(:remounts).returns(:true)
@mounter.stubs(:mountcmd)
@mounter.expects(:info).with("Remounting")
@mounter.remount
end
end
describe Puppet::Provider::Mount, " when unmounting" do
it "should call the :umount command with the resource name" do
@mounter.expects(:umount).with(@name)
@mounter.unmount
end
end
describe Puppet::Provider::Mount, " when determining if it is mounted" do
it "should parse the results of running the mount command with no arguments" do
Facter.stubs(:value).returns("whatever")
@mounter.expects(:mountcmd).returns("")
@mounter.mounted?
end
it "should match ' on /private/var/automount<name>' if the operating system is Darwin" do
Facter.stubs(:value).with("operatingsystem").returns("Darwin")
@mounter.expects(:mountcmd).returns("/dev/whatever on /private/var/automount/\ndevfs on /dev")
@mounter.should be_mounted
end
it "should match ' on <name>' if the operating system is Darwin" do
Facter.stubs(:value).with("operatingsystem").returns("Darwin")
@mounter.expects(:mountcmd).returns("/dev/disk03 on / (local, journaled)\ndevfs on /dev")
@mounter.should be_mounted
end
it "should match '^<name> on' if the operating system is Solaris" do
Facter.stubs(:value).with("operatingsystem").returns("Solaris")
@mounter.expects(:mountcmd).returns("/ on /dev/dsk/whatever\n/var on /dev/dsk/other")
@mounter.should be_mounted
end
it "should match '^<name> on' if the operating system is HP-UX" do
Facter.stubs(:value).with("operatingsystem").returns("HP-UX")
@mounter.expects(:mountcmd).returns("/ on /dev/dsk/whatever\n/var on /dev/dsk/other")
@mounter.should be_mounted
end
it "should match ' on <name>' if the operating system is not Darwin, Solaris, or HP-UX" do
Facter.stubs(:value).with("operatingsystem").returns("Debian")
@mounter.expects(:mountcmd).returns("/dev/dsk/whatever on / and stuff\n/dev/other/disk on /var and stuff")
@mounter.should be_mounted
end
it "should not be considered mounted if it did not match the mount output" do
Facter.stubs(:value).with("operatingsystem").returns("Debian")
@mounter.expects(:mountcmd).returns("/dev/dsk/whatever on /something/else and stuff\n/dev/other/disk on /var and stuff")
@mounter.should_not be_mounted
end
end
end
|