diff options
author | Tommy Bishop <bishop.thomas@gmail.com> | 2011-06-01 16:36:02 -0700 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2011-07-19 09:20:59 -0700 |
commit | 7c175ac2e59693b0d826ce09e36ca776bb3cdec2 (patch) | |
tree | 4f9362027c37ffade55a9539b92c407711c2b2e4 /chef/spec | |
parent | 51df245bc2a36082439e252d77f78936c51e49bf (diff) | |
download | chef-7c175ac2e59693b0d826ce09e36ca776bb3cdec2.tar.gz |
[CHEF-2394] Raise an error if the data_bag_path is invalid for solo mode
Diffstat (limited to 'chef/spec')
-rw-r--r-- | chef/spec/unit/data_bag_spec.rb | 10 | ||||
-rw-r--r-- | chef/spec/unit/exceptions_spec.rb | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/chef/spec/unit/data_bag_spec.rb b/chef/spec/unit/data_bag_spec.rb index 89d28de78f..e1294d2577 100644 --- a/chef/spec/unit/data_bag_spec.rb +++ b/chef/spec/unit/data_bag_spec.rb @@ -101,11 +101,13 @@ describe Chef::DataBag do end it "should get the data bag from the data_bag_path" do + File.should_receive(:directory?).with('/var/chef/data_bags').and_return(true) Dir.should_receive(:glob).with('/var/chef/data_bags/foo/*.json').and_return([]) Chef::DataBag.load('foo') end it "should return the data bag" do + File.should_receive(:directory?).with('/var/chef/data_bags').and_return(true) Dir.stub!(:glob).and_return(["/var/chef/data_bags/foo/bar.json", "/var/chef/data_bags/foo/baz.json"]) IO.should_receive(:read).with('/var/chef/data_bags/foo/bar.json').and_return('{"id": "bar", "name": "Bob Bar" }') IO.should_receive(:read).with('/var/chef/data_bags/foo/baz.json').and_return('{"id": "baz", "name": "John Baz" }') @@ -113,6 +115,14 @@ describe Chef::DataBag do data_bag.should == { 'bar' => { 'id' => 'bar', 'name' => 'Bob Bar' }, 'baz' => { 'id' => 'baz', 'name' => 'John Baz' }} end + it 'should raise an error if the configured data_bag_path is invalid' do + File.should_receive(:directory?).with('/var/chef/data_bags').and_return(false) + + lambda { + Chef::DataBag.load('foo') + }.should raise_error Chef::Exceptions::InvalidDataBagPath, "Data bag path '/var/chef/data_bags' is invalid" + end + end end diff --git a/chef/spec/unit/exceptions_spec.rb b/chef/spec/unit/exceptions_spec.rb index 388bbb0885..b24cdb6151 100644 --- a/chef/spec/unit/exceptions_spec.rb +++ b/chef/spec/unit/exceptions_spec.rb @@ -62,7 +62,8 @@ describe Chef::Exceptions do Chef::Exceptions::InvalidResourceReference => RuntimeError, Chef::Exceptions::ResourceNotFound => RuntimeError, Chef::Exceptions::InvalidResourceSpecification => ArgumentError, - Chef::Exceptions::SolrConnectionError => RuntimeError + Chef::Exceptions::SolrConnectionError => RuntimeError, + Chef::Exceptions::InvalidDataBagPath => ArgumentError } exception_to_super_class.each do |exception, expected_super_class| |