diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/integration/provider/mount_spec.rb | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/spec/integration/provider/mount_spec.rb b/spec/integration/provider/mount_spec.rb index a62505d6d..d6f25fe1d 100644 --- a/spec/integration/provider/mount_spec.rb +++ b/spec/integration/provider/mount_spec.rb @@ -16,6 +16,7 @@ describe "mount provider (integration)" do before :each do @fake_fstab = tmpfile('fstab') @current_options = "local" + @current_device = "/dev/disk1s1" Puppet::Type.type(:mount).defaultprovider.stubs(:default_target).returns(@fake_fstab) Facter.stubs(:value).with(:operatingsystem).returns('Darwin') Puppet::Util::ExecutionStub.set do |command, options| @@ -23,7 +24,7 @@ describe "mount provider (integration)" do when %r{/s?bin/mount} if command.length == 1 if @mounted - "/dev/disk1s1 on /Volumes/foo_disk (msdos, #{@current_options})\n" + "#{@current_device} on /Volumes/foo_disk (msdos, #{@current_options})\n" else '' end @@ -33,7 +34,7 @@ describe "mount provider (integration)" do command[3].should == '/Volumes/foo_disk' @mounted.should == false # verify that we don't try to call "mount" redundantly @current_options = command[2] - check_fstab(true) + @current_device = check_fstab(true) @mounted = true '' end @@ -55,8 +56,16 @@ describe "mount provider (integration)" do def check_fstab(expected_to_be_present) # Verify that the fake fstab has the expected data in it - expected_data = expected_to_be_present ? ["/dev/disk1s1\t/Volumes/foo_disk\tmsdos\t#{@desired_options}\t0\t0"] : [] - File.read(@fake_fstab).lines.map(&:chomp).reject { |x| x =~ /^#|^$/ }.should == expected_data + fstab_contents = File.read(@fake_fstab).lines.map(&:chomp).reject { |x| x =~ /^#|^$/ } + if expected_to_be_present + fstab_contents.length().should == 1 + device, rest_of_line = fstab_contents[0].split(/\t/,2) + rest_of_line.should == "/Volumes/foo_disk\tmsdos\t#{@desired_options}\t0\t0" + device + else + fstab_contents.length().should == 0 + nil + end end def run_in_catalog(settings) @@ -101,7 +110,11 @@ describe "mount provider (integration)" do @desired_options = options_setting run_in_catalog(:ensure=>ensure_setting, :options => options_setting) @mounted.should == expected_final_state - check_fstab(expected_fstab_data) + if expected_fstab_data + check_fstab(expected_fstab_data).should == "/dev/disk1s1" + else + check_fstab(expected_fstab_data).should == nil + end if @mounted if ![:defined, :present].include?(ensure_setting) @current_options.should == @desired_options @@ -120,4 +133,19 @@ describe "mount provider (integration)" do end end end + + describe "When the wrong device is mounted" do + it "should remount the correct device" do + pending "Due to bug 6309" + @mounted = true + @current_device = "/dev/disk2s2" + create_fake_fstab(true) + @desired_options = "local" + run_in_catalog(:ensure=>:mounted, :options=>'local') + @current_device.should=="/dev/disk1s1" + @mounted.should==true + @current_options.should=='local' + check_fstab(true).should == "/dev/disk1s1" + end + end end |