summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalim Alam <salam@chef.io>2016-03-11 10:59:01 -0800
committerSalim Alam <salam@chef.io>2016-03-11 10:59:01 -0800
commit7d32b4b636a271533d07f35c478bf4ca7108a25f (patch)
tree0fc9848b32caeb809bf9561e705c10300576322e
parent7f970035bee3ea4ac0c582df0fcffaf3df516d6d (diff)
parent0c4249a6d822e4ff7034f099f6757b8543f75543 (diff)
downloadchef-7d32b4b636a271533d07f35c478bf4ca7108a25f.tar.gz
Merge pull request #4692 from chef/salam/mount-fix
Make mount idempotent on Windows
-rw-r--r--lib/chef/provider/mount/windows.rb6
-rw-r--r--spec/unit/provider/mount/windows_spec.rb12
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/chef/provider/mount/windows.rb b/lib/chef/provider/mount/windows.rb
index 3ffe326cac..0fb5aa7645 100644
--- a/lib/chef/provider/mount/windows.rb
+++ b/lib/chef/provider/mount/windows.rb
@@ -80,6 +80,12 @@ class Chef
end
end
+ private
+
+ def mount_options_unchanged?
+ @current_resource.device == @new_resource.device
+ end
+
end
end
end
diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb
index ab7a161c08..ec1945de50 100644
--- a/spec/unit/provider/mount/windows_spec.rb
+++ b/spec/unit/provider/mount/windows_spec.rb
@@ -120,6 +120,18 @@ describe Chef::Provider::Mount::Windows do
@provider.mount_fs
end
+ context "mount_options_unchanged?" do
+ it "should return true if mounted device is the same" do
+ allow(@current_resource).to receive(:device).and_return(GUID)
+ expect(@provider.send :mount_options_unchanged?).to be true
+ end
+
+ it "should return false if mounted device has changed" do
+ allow(@current_resource).to receive(:device).and_return("XXXX")
+ expect(@provider.send :mount_options_unchanged?).to be false
+ end
+ end
+
it "should not mount the filesystem if it is mounted and the options have not changed" do
expect(@vol).to_not receive(:add)
allow(@current_resource).to receive(:mounted).and_return(true)