summaryrefslogtreecommitdiff
path: root/spec/unit/provider/mdadm_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider/mdadm_spec.rb')
-rw-r--r--spec/unit/provider/mdadm_spec.rb33
1 files changed, 21 insertions, 12 deletions
diff --git a/spec/unit/provider/mdadm_spec.rb b/spec/unit/provider/mdadm_spec.rb
index 77ed5798a8..8ef884e131 100644
--- a/spec/unit/provider/mdadm_spec.rb
+++ b/spec/unit/provider/mdadm_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Joe Williams (<joe@joetify.com>)
-# Copyright:: Copyright (c) 2009 Joe Williams
+# Copyright:: Copyright 2009-2016, Joe Williams
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'ostruct'
+require "spec_helper"
+require "ostruct"
describe Chef::Provider::Mdadm do
@@ -25,8 +25,8 @@ describe Chef::Provider::Mdadm do
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
- @new_resource = Chef::Resource::Mdadm.new('/dev/md1')
- @new_resource.devices ["/dev/sdz1","/dev/sdz2","/dev/sdz3"]
+ @new_resource = Chef::Resource::Mdadm.new("/dev/md1")
+ @new_resource.devices ["/dev/sdz1", "/dev/sdz2", "/dev/sdz3"]
@provider = Chef::Provider::Mdadm.new(@new_resource, @run_context)
end
@@ -34,18 +34,18 @@ describe Chef::Provider::Mdadm do
it "should set the current resources mount point to the new resources mount point" do
allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:status => 0))
@provider.load_current_resource
- expect(@provider.current_resource.name).to eq('/dev/md1')
- expect(@provider.current_resource.raid_device).to eq('/dev/md1')
+ expect(@provider.current_resource.name).to eq("/dev/md1")
+ expect(@provider.current_resource.raid_device).to eq("/dev/md1")
end
it "determines that the metadevice exists when mdadm exit code is zero" do
- allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0,4]).and_return(OpenStruct.new(:status => 0))
+ allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0, 4]).and_return(OpenStruct.new(:status => 0))
@provider.load_current_resource
expect(@provider.current_resource.exists).to be_truthy
end
it "determines that the metadevice does not exist when mdadm exit code is 4" do
- allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0,4]).and_return(OpenStruct.new(:status => 4))
+ allow(@provider).to receive(:shell_out!).with("mdadm --detail --test /dev/md1", :returns => [0, 4]).and_return(OpenStruct.new(:status => 4))
@provider.load_current_resource
expect(@provider.current_resource.exists).to be_falsey
end
@@ -53,7 +53,7 @@ describe Chef::Provider::Mdadm do
describe "after the metadevice status is known" do
before(:each) do
- @current_resource = Chef::Resource::Mdadm.new('/dev/md1')
+ @current_resource = Chef::Resource::Mdadm.new("/dev/md1")
@new_resource.level 5
allow(@provider).to receive(:load_current_resource).and_return(true)
@provider.current_resource = @current_resource
@@ -69,13 +69,22 @@ describe Chef::Provider::Mdadm do
it "should specify a bitmap only if set" do
@current_resource.exists(false)
- @new_resource.bitmap('grow')
+ @new_resource.bitmap("grow")
expected_command = "yes | mdadm --create /dev/md1 --level 5 --chunk=16 --metadata=0.90 --bitmap=grow --raid-devices 3 /dev/sdz1 /dev/sdz2 /dev/sdz3"
expect(@provider).to receive(:shell_out!).with(expected_command)
@provider.run_action(:create)
expect(@new_resource).to be_updated_by_last_action
end
+ it "should specify a layout only if set" do
+ @current_resource.exists(false)
+ @new_resource.layout("rs")
+ expected_command = "yes | mdadm --create /dev/md1 --level 5 --chunk=16 --metadata=0.90 --layout=rs --raid-devices 3 /dev/sdz1 /dev/sdz2 /dev/sdz3"
+ expect(@provider).to receive(:shell_out!).with(expected_command)
+ @provider.run_action(:create)
+ expect(@new_resource).to be_updated_by_last_action
+ end
+
it "should not specify a chunksize if raid level 1" do
@current_resource.exists(false)
@new_resource.level 1
@@ -102,7 +111,7 @@ describe Chef::Provider::Mdadm do
expect(@new_resource).to be_updated_by_last_action
end
- it "should not assemble the raid device if it doesnt exist" do
+ it "should not assemble the raid device if it doesnt exist" do
@current_resource.exists(true)
expect(@provider).not_to receive(:shell_out!)
@provider.run_action(:assemble)