summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChibuikem Amaechi <cramaechi@me.com>2018-01-29 23:09:24 -0600
committerChibuikem Amaechi <cramaechi@me.com>2018-01-29 23:16:35 -0600
commit4f394f02120882f41909e742d763ab382f88682e (patch)
tree16a98fa5b381fa8f5fed8eb6100f395791d080eb
parent0f45f8e107980a2cd49d4786fe5abd77b8085713 (diff)
downloadchef-4f394f02120882f41909e742d763ab382f88682e.tar.gz
Update logic in mount/mount.rb and mount/mount_spec.rb
Signed-off-by: Chibuikem Amaechi <cramaechi@me.com>
-rw-r--r--lib/chef/provider/mount/mount.rb12
-rw-r--r--spec/unit/provider/mount/mount_spec.rb20
2 files changed, 20 insertions, 12 deletions
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb
index 35336b4b4c..0be45e80da 100644
--- a/lib/chef/provider/mount/mount.rb
+++ b/lib/chef/provider/mount/mount.rb
@@ -146,13 +146,9 @@ class Chef
end
end
- # Return appropriate default mount options according to the input os.
- def default_mount_options(os)
- if os == "freebsd"
- "rw"
- else
- "defaults"
- end
+ # Return appropriate default mount options according to the given os.
+ def default_mount_options
+ node[:os] == "linux" ? "defaults" : "rw"
end
def enable_fs
@@ -167,7 +163,7 @@ class Chef
disable_fs
end
::File.open("/etc/fstab", "a") do |fstab|
- fstab.puts("#{device_fstab} #{@new_resource.mount_point} #{@new_resource.fstype} #{@new_resource.options.nil? ? default_mount_options(node[:os]) : @new_resource.options.join(",")} #{@new_resource.dump} #{@new_resource.pass}")
+ fstab.puts("#{device_fstab} #{@new_resource.mount_point} #{@new_resource.fstype} #{@new_resource.options.nil? ? default_mount_options : @new_resource.options.join(",")} #{@new_resource.dump} #{@new_resource.pass}")
Chef::Log.debug("#{@new_resource} is enabled at #{@new_resource.mount_point}")
end
end
diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb
index 908635e958..b61dc65800 100644
--- a/spec/unit/provider/mount/mount_spec.rb
+++ b/spec/unit/provider/mount/mount_spec.rb
@@ -375,12 +375,24 @@ describe Chef::Provider::Mount::Mount do
end
describe "default_mount_options" do
- it "should return the correct default mount options for FreeBSD" do
- expect(@provider.default_mount_options("freebsd")).to eq("rw")
+ it "should return the correct default mount options for Linux" do
+ @provider.node.override[:os] = "linux"
+ expect(@provider.default_mount_options).to eq("defaults")
end
- it "should return the correct default mount options for Linux" do
- expect(@provider.default_mount_options("linux")).to eq("defaults")
+ it "should return the correct default mount options for AIX" do
+ @provider.node.override[:os] = "aix"
+ expect(@provider.default_mount_options).to eq("rw")
+ end
+
+ it "should return the correct default mount options for Darwin" do
+ @provider.node.override[:os] = "darwin"
+ expect(@provider.default_mount_options).to eq("rw")
+ end
+
+ it "should return the correct default mount options for FreeBSD" do
+ @provider.node.override[:os] = "freebsd"
+ expect(@provider.default_mount_options).to eq("rw")
end
end