diff options
author | John Keiser <jkeiser@opscode.com> | 2013-05-28 13:15:40 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-05-28 13:15:40 -0700 |
commit | 3db27d5466b9c0335c0bc7f2e8adbc69bc1cae10 (patch) | |
tree | 606d66cafc56f5fda819740474df5d04353d3c6e | |
parent | 7dbde11ea5d97fe29e9c824116bbcf7f2a7b7b0c (diff) | |
download | chef-zero-3db27d5466b9c0335c0bc7f2e8adbc69bc1cae10.tar.gz |
Fix new data bag and cookbook creation in rspec
-rw-r--r-- | lib/chef_zero/data_store/memory_store.rb | 7 | ||||
-rw-r--r-- | lib/chef_zero/endpoints/data_bags_endpoint.rb | 2 | ||||
-rw-r--r-- | lib/chef_zero/server.rb | 6 |
3 files changed, 9 insertions, 6 deletions
diff --git a/lib/chef_zero/data_store/memory_store.rb b/lib/chef_zero/data_store/memory_store.rb index 431a877..42d1953 100644 --- a/lib/chef_zero/data_store/memory_store.rb +++ b/lib/chef_zero/data_store/memory_store.rb @@ -52,9 +52,12 @@ module ChefZero parent = _get(path, options.include?(:recursive)) if parent.has_key?(name) - raise DataAlreadyExistsError.new(path + [name]) + if !options.include?(:recursive) + raise DataAlreadyExistsError.new(path + [name]) + end + else + parent[name] = {} end - parent[name] = {} end def create(path, name, data, *options) diff --git a/lib/chef_zero/endpoints/data_bags_endpoint.rb b/lib/chef_zero/endpoints/data_bags_endpoint.rb index 0b29769..7b50ea9 100644 --- a/lib/chef_zero/endpoints/data_bags_endpoint.rb +++ b/lib/chef_zero/endpoints/data_bags_endpoint.rb @@ -13,7 +13,7 @@ module ChefZero elsif exists_data_dir?(request, ['data', name]) error(409, "Object already exists") else - data_store.create_dir(['data'], name, :keep_existing) + data_store.create_dir(['data'], name, :recursive) json_response(201, {"uri" => "#{build_uri(request.base_uri, request.rest_path + [name])}"}) end end diff --git a/lib/chef_zero/server.rb b/lib/chef_zero/server.rb index 3fcba13..4114b46 100644 --- a/lib/chef_zero/server.rb +++ b/lib/chef_zero/server.rb @@ -188,9 +188,9 @@ module ChefZero end if contents['data'] contents['data'].each_pair do |key, data_bag| - data_store.create_dir(['data'], key, :keep_existing) + data_store.create_dir(['data'], key, :recursive) dejsonize_children(data_bag).each do |item_name, item| - data_store.set(['data', key], item_name, item, :create) + data_store.set(['data', key, item_name], item, :create) end end end @@ -202,7 +202,7 @@ module ChefZero cookbook_data = CookbookData.to_hash(cookbook, name_version) end raise "No version specified" if !cookbook_data[:version] - data_store.create_dir(['cookbooks'], cookbook_data[:cookbook_name], :keep_existing) + data_store.create_dir(['cookbooks'], cookbook_data[:cookbook_name], :recursive) data_store.set(['cookbooks', cookbook_data[:cookbook_name], cookbook_data[:version]], JSON.pretty_generate(cookbook_data), :create) cookbook_data.values.each do |files| next unless files.is_a? Array |