Whoops, a minor typo with rake mail_patches made it look like Why The Lucky Stiff worked on this patch with us. Sorry to disappoint y'all, it was just me and Max.
On Tue, Mar 8, 2011 at 3:13 PM, <[email protected]> wrote: > From: Paul Berry <[email protected]> > > Paired-with: Max Martin <[email protected]> > Signed-off-by: Max Martin <[email protected]> > --- > spec/integration/provider/mount_spec.rb | 99 > ++++++++++++++++++++----------- > 1 files changed, 64 insertions(+), 35 deletions(-) > > diff --git a/spec/integration/provider/mount_spec.rb > b/spec/integration/provider/mount_spec.rb > index 518b295..a62505d 100644 > --- a/spec/integration/provider/mount_spec.rb > +++ b/spec/integration/provider/mount_spec.rb > @@ -5,11 +5,17 @@ require 'puppet/file_bucket/dipper' > describe "mount provider (integration)" do > include PuppetSpec::Files > > - before :each do > - @fake_fstab = tmpfile('fstab') > + def create_fake_fstab(initially_contains_entry) > File.open(@fake_fstab, 'w') do |f| > - # leave file empty > + if initially_contains_entry > + f.puts("/dev/disk1s1\t/Volumes/foo_disk\tmsdos\tlocal\t0\t0") > + end > end > + end > + > + before :each do > + @fake_fstab = tmpfile('fstab') > + @current_options = "local" > > 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| > @@ -17,22 +23,21 @@ describe "mount provider (integration)" do > when %r{/s?bin/mount} > if command.length == 1 > if @mounted > - "/dev/disk1s1 on /Volumes/foo_disk (msdos, local)\n" > + "/dev/disk1s1 on /Volumes/foo_disk (msdos, > #{@current_options})\n" > else > '' > end > else > command.length.should == 4 > command[1].should == '-o' > - command[2].should == 'local' > command[3].should == '/Volumes/foo_disk' > @mounted.should == false # verify that we don't try to call > "mount" redundantly > - check_fstab > + @current_options = command[2] > + check_fstab(true) > @mounted = true > '' > end > when %r{/s?bin/umount} > - fail "unexpected umount" unless @umount_permitted > command.length.should == 2 > command[1].should == '/Volumes/foo_disk' > @mounted.should == true # "umount" doesn't work when device not > mounted (see #6632) > @@ -48,14 +53,15 @@ describe "mount provider (integration)" do > Puppet::Type::Mount::ProviderParsed.clear # Work around bug #6628 > end > > - def check_fstab > + def check_fstab(expected_to_be_present) > # Verify that the fake fstab has the expected data in it > - File.read(@fake_fstab).lines.reject { |x| x =~ /^#/ }.should == > ["/dev/disk1s1\t/Volumes/foo_disk\tmsdos\tlocal\t0\t0\n"] > + 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 > end > > - def run_in_catalog(ensure_setting) > - resource = Puppet::Type.type(:mount).new(:name => "/Volumes/foo_disk", > :ensure => ensure_setting, > - :device => "/dev/disk1s1", > :options => "local", :fstype => "msdos") > + def run_in_catalog(settings) > + resource = Puppet::Type.type(:mount).new(settings.merge(:name => > "/Volumes/foo_disk", > + :device => "/dev/disk1s1", > :fstype => "msdos")) > Puppet::FileBucket::Dipper.any_instance.stubs(:backup) # Don't backup > to the filebucket > resource.expects(:err).never > catalog = Puppet::Resource::Catalog.new > @@ -64,31 +70,54 @@ describe "mount provider (integration)" do > catalog.apply > end > > - [:defined, :present].each do |ensure_setting| > - describe "When setting ensure => #{ensure_setting}" do > - it "should create an fstab entry if none exists" do > - @mounted = false > - @umount_permitted = false > - run_in_catalog(ensure_setting) > - @mounted.should == false > - check_fstab > + [false, true].each do |initial_state| > + describe "When initially #{initial_state ? 'mounted' : 'unmounted'}" > do > + before :each do > + @mounted = initial_state > end > - end > - end > > - it "should be able to create and mount a brand new mount point" do > - @mounted = false > - @umount_permitted = true # Work around bug #6633 > - run_in_catalog(:mounted) > - @mounted.should == true > - check_fstab > - end > + [false, true].each do |initial_fstab_entry| > + describe "When there is #{initial_fstab_entry ? 'an' : 'no'} > initial fstab entry" do > + before :each do > + create_fake_fstab(initial_fstab_entry) > + end > > - it "should be able to create an fstab entry for an already-mounted > device" do > - @mounted = true > - @umount_permitted = true # Work around bug #6633 > - run_in_catalog(:mounted) > - @mounted.should == true > - check_fstab > + [:defined, :present, :mounted, :unmounted, :absent].each do > |ensure_setting| > + expected_final_state = case ensure_setting > + when :mounted > + true > + when :unmounted, :absent > + false > + when :defined, :present > + initial_state > + else > + fail "Unknown ensure_setting #{ensure_setting}" > + end > + expected_fstab_data = (ensure_setting != :absent) > + describe "When setting ensure => #{ensure_setting}" do > + ["local", "journaled"].each do |options_setting| > + describe "When setting options => #{options_setting}" do > + it "should leave the system in the > #{expected_final_state ? 'mounted' : 'unmounted'} state, > #{expected_fstab_data ? 'with' : 'without'} data in /etc/fstab" 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 @mounted > + if ![:defined, :present].include?(ensure_setting) > + @current_options.should == @desired_options > + elsif initial_fstab_entry > + @current_options.should == @desired_options > + else > + @current_options.should == 'local' #Workaround for > #6645 > + end > + end > + end > + end > + end > + end > + end > + end > + end > + end > end > end > -- > 1.7.4 > > -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
