summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorantima-gupta <agupta@msystechnologies.com>2020-10-28 17:32:29 +0530
committerantima-gupta <agupta@msystechnologies.com>2020-10-28 17:32:29 +0530
commit7fe69a2a865e24314540e2c8a9c0d28375b22eed (patch)
tree4d23df7aeb6bd0f70b795edfea5818db1140d3fc /spec
parenta8ead1a6bbbbda2eae75bc1fdc4c9858d15c81cb (diff)
downloadchef-7fe69a2a865e24314540e2c8a9c0d28375b22eed.tar.gz
Moved device_fstab method from provider/mount/mount.rb to provider/mount.rb.
Compare current resource device with new resource device_fstab value. Added specs for device_unchaged? method changes. Signed-off-by: antima-gupta <agupta@msystechnologies.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/provider/mount_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/unit/provider/mount_spec.rb b/spec/unit/provider/mount_spec.rb
index f41be7bd3b..47bab39e66 100644
--- a/spec/unit/provider/mount_spec.rb
+++ b/spec/unit/provider/mount_spec.rb
@@ -151,6 +151,24 @@ describe Chef::Provider::Mount do
provider.run_action(:enable)
expect(new_resource).not_to be_updated_by_last_action
end
+
+ it "should enable the mount if device changed" do
+ allow(current_resource).to receive(:enabled).and_return(true)
+ expect(provider).to receive(:mount_options_unchanged?).and_return(true)
+ expect(provider).to receive(:device_unchanged?).and_return(false)
+ expect(provider).to receive(:enable_fs).and_return(true)
+ provider.run_action(:enable)
+ expect(new_resource).to be_updated_by_last_action
+ end
+
+ it "should not enable the mount if device not changed" do
+ allow(current_resource).to receive(:enabled).and_return(true)
+ expect(provider).to receive(:mount_options_unchanged?).and_return(true)
+ expect(provider).to receive(:device_unchanged?).and_return(true)
+ expect(provider).not_to receive(:enable_fs)
+ provider.run_action(:enable)
+ expect(new_resource).not_to be_updated_by_last_action
+ end
end
describe "when the target state is to disable the mount" do
@@ -188,4 +206,16 @@ describe Chef::Provider::Mount do
it "should delegates the disable implementation to subclasses" do
expect { provider.disable_fs }.to raise_error(Chef::Exceptions::UnsupportedAction)
end
+
+ describe "#device_unchanged?" do
+ it "should be true when device_type not changed" do
+ expect(provider.device_unchanged?).to be_truthy
+ end
+
+ it "should be false when device_type changed" do
+ new_resource.device_type :label
+ current_resource.device_type :device
+ expect(provider.device_unchanged?).to be_falsey
+ end
+ end
end