diff options
author | Salim Alam <salam@chef.io> | 2016-03-11 10:59:01 -0800 |
---|---|---|
committer | Salim Alam <salam@chef.io> | 2016-03-11 10:59:01 -0800 |
commit | 7d32b4b636a271533d07f35c478bf4ca7108a25f (patch) | |
tree | 0fc9848b32caeb809bf9561e705c10300576322e | |
parent | 7f970035bee3ea4ac0c582df0fcffaf3df516d6d (diff) | |
parent | 0c4249a6d822e4ff7034f099f6757b8543f75543 (diff) | |
download | chef-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.rb | 6 | ||||
-rw-r--r-- | spec/unit/provider/mount/windows_spec.rb | 12 |
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) |