summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2015-03-24 18:14:57 -0700
committerdanielsdeleo <dan@getchef.com>2015-03-25 08:13:34 -0700
commit93c669196f53d21cf2b973b014c2cde4e0c3313a (patch)
tree59bd141848d7036167cdc6522491f24ae788bb9d /spec
parenta6fbf127d3eeb38d73fa4b9aec98ef34cf897f85 (diff)
downloadchef-93c669196f53d21cf2b973b014c2cde4e0c3313a.tar.gz
Handle cookbook artfact format differences when fetching cookbookspolicyfile-erchef-integration
Cookbook artifacts differ in these ways: * the name field is the cookbook name instead of name+version * there is no "cookbook_name" field * cookbook artifacts don't have a json_class when downloaded from the server * there is an identifier field
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/cookbook/file_vendor_spec.rb36
1 files changed, 28 insertions, 8 deletions
diff --git a/spec/unit/cookbook/file_vendor_spec.rb b/spec/unit/cookbook/file_vendor_spec.rb
index 4fad7d5808..145541a63f 100644
--- a/spec/unit/cookbook/file_vendor_spec.rb
+++ b/spec/unit/cookbook/file_vendor_spec.rb
@@ -21,9 +21,6 @@ describe Chef::Cookbook::FileVendor do
let(:file_vendor_class) { Class.new(described_class) }
- # A manifest is a Hash of the format defined by Chef::CookbookVersion#manifest
- let(:manifest) { {:cookbook_name => "bob"} }
-
context "when configured to fetch files over http" do
let(:http) { double("Chef::REST") }
@@ -40,19 +37,42 @@ describe Chef::Cookbook::FileVendor do
expect(file_vendor_class.initialization_options).to eq(http)
end
- it "creates a RemoteFileVendor for a given manifest" do
- file_vendor = file_vendor_class.create_from_manifest(manifest)
- expect(file_vendor).to be_a_kind_of(Chef::Cookbook::RemoteFileVendor)
- expect(file_vendor.rest).to eq(http)
- expect(file_vendor.cookbook_name).to eq("bob")
+ context "with a manifest from a cookbook version" do
+
+ # A manifest is a Hash of the format defined by Chef::CookbookVersion#manifest
+ let(:manifest) { {:cookbook_name => "bob", :name => "bob-1.2.3"} }
+
+ it "creates a RemoteFileVendor for a given manifest" do
+ file_vendor = file_vendor_class.create_from_manifest(manifest)
+ expect(file_vendor).to be_a_kind_of(Chef::Cookbook::RemoteFileVendor)
+ expect(file_vendor.rest).to eq(http)
+ expect(file_vendor.cookbook_name).to eq("bob")
+ end
+
end
+ context "with a manifest from a cookbook artifact" do
+
+ # A manifest is a Hash of the format defined by Chef::CookbookVersion#manifest
+ let(:manifest) { {:name => "bob"} }
+
+ it "creates a RemoteFileVendor for a given manifest" do
+ file_vendor = file_vendor_class.create_from_manifest(manifest)
+ expect(file_vendor).to be_a_kind_of(Chef::Cookbook::RemoteFileVendor)
+ expect(file_vendor.rest).to eq(http)
+ expect(file_vendor.cookbook_name).to eq("bob")
+ end
+
+ end
end
context "when configured to load files from disk" do
let(:cookbook_path) { %w[/var/chef/cookbooks /var/chef/other_cookbooks] }
+ # A manifest is a Hash of the format defined by Chef::CookbookVersion#manifest
+ let(:manifest) { {:cookbook_name => "bob"} }
+
before do
file_vendor_class.fetch_from_disk(cookbook_path)
end