summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Belchamber <james@belchamber.com>2014-08-12 09:30:38 +0100
committerLamont Granquist <lamont@scriptkiddie.org>2015-08-18 12:15:44 -0700
commit7841cd0a6864600012c2fe43c8483c3baea844e2 (patch)
treec9174de4bd9c95600578f95b30ad1b6dcddb8774
parent2696a360c09856e1dc0fab754d3b00143b147853 (diff)
downloadchef-7841cd0a6864600012c2fe43c8483c3baea844e2.tar.gz
added tests for mount remounting
-rw-r--r--spec/unit/provider/mount/mount_spec.rb13
-rw-r--r--spec/unit/provider/mount/windows_spec.rb14
-rw-r--r--spec/unit/provider/mount_spec.rb11
3 files changed, 37 insertions, 1 deletions
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index 7a37ffe74e..ef9031f24b 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -323,6 +323,19 @@ describe Chef::Provider::Mount::Mount do
@provider.mount_fs()
end
+ it "should remount the filesystem if it is mounted and the options have changed" do
+ options = "rw,noexec,noauto"
+ @new_resource.options(%w{rw exec auto})
+ @provider.should_receive(:shell_out!).with("mount -t ext3 -o remount,rw,exec,auto /dev/sdz1 /tmp/foo")
+ @provider.mount_fs()
+ end
+
+ it "should not mount the filesystem if it is mounted and the options have not changed" do
+ @current_resource.stub(:mounted).and_return(true)
+ @provider.should_not_receive(:shell_out!)
+ @provider.mount_fs()
+ end
+
end
describe "umount_fs" do
diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb
index 467d923c6a..4ceab38aa6 100644
--- a/spec/unit/provider/mount/windows_spec.rb
+++ b/spec/unit/provider/mount/windows_spec.rb
@@ -111,6 +111,20 @@ describe Chef::Provider::Mount::Windows do
allow(@current_resource).to receive(:mounted).and_return(true)
@provider.mount_fs
end
+
+ it "should remount the filesystem if it is mounted and the options have changed" do
+ @vol.should_receive(:add).with(:remote => @new_resource.device,
+ :username => @new_resource.username,
+ :domainname => @new_resource.domain,
+ :password => @new_resource.password)
+ @provider.mount_fs
+ end
+
+ it "should not mount the filesystem if it is mounted and the options have not changed" do
+ @vol.should_not_receive(:add)
+ @current_resource.stub(:mounted).and_return(true)
+ @provider.mount_fs
+ end
end
describe "when unmounting a file system" do
diff --git a/spec/unit/provider/mount_spec.rb b/spec/unit/provider/mount_spec.rb
index e9fe3fa050..5647613691 100644
--- a/spec/unit/provider/mount_spec.rb
+++ b/spec/unit/provider/mount_spec.rb
@@ -61,8 +61,17 @@ describe Chef::Provider::Mount do
expect(new_resource).to be_updated_by_last_action
end
- it "should not mount the filesystem if it is mounted" do
+ it "should remount the filesystem if it is mounted and the options have changed" do
allow(current_resource).to receive(:mounted).and_return(true)
+ expect(provider).to receive(:mount_options_unchanged?).and_return(false)
+ expect(provider).to receive(:mount_fs).and_return(true)
+ provider.run_action(:mount)
+ expect(new_resource).to be_updated_by_last_action
+ end
+
+ it "should not mount the filesystem if it is mounted and the options have not changed" do
+ allow(current_resource).to receive(:mounted).and_return(true)
+ expect(provider).to receive(:mount_options_unchanged?).and_return(true)
expect(provider).not_to receive(:mount_fs)
provider.run_action(:mount)
expect(new_resource).not_to be_updated_by_last_action