summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2010-06-06 17:27:19 -0700
committerDaniel DeLeo <dan@opscode.com>2010-06-06 17:27:19 -0700
commitd13a6a34bdb9bb31dd8bdcfd0e325078deb8e0c2 (patch)
tree8ae7261447f5934314337a7e7f0e8ccd39ddb7a1
parent26fdd995536e530cb4d8fcdf676adcefe36b4aee (diff)
downloadchef-d13a6a34bdb9bb31dd8bdcfd0e325078deb8e0c2.tar.gz
fix up test harness for recent changes
-rw-r--r--chef/lib/chef/cookbook_loader.rb5
-rw-r--r--features/api/cookbooks/upload_cookbooks.feature2
-rw-r--r--features/cookbooks/metadata.feature5
-rw-r--r--features/steps/cookbook_steps.rb19
4 files changed, 25 insertions, 6 deletions
diff --git a/chef/lib/chef/cookbook_loader.rb b/chef/lib/chef/cookbook_loader.rb
index a992112a42..b8f06fa86e 100644
--- a/chef/lib/chef/cookbook_loader.rb
+++ b/chef/lib/chef/cookbook_loader.rb
@@ -161,9 +161,14 @@ class Chef
end
end
+ def cookbook_names
+ @cookbooks_by_name.keys.sort
+ end
+
def values
@cookbooks_by_name.values
end
+ alias :cookbooks :values
private
diff --git a/features/api/cookbooks/upload_cookbooks.feature b/features/api/cookbooks/upload_cookbooks.feature
index 3f512668fd..cf9f51a66a 100644
--- a/features/api/cookbooks/upload_cookbooks.feature
+++ b/features/api/cookbooks/upload_cookbooks.feature
@@ -115,5 +115,5 @@ Feature: CRUD cookbooks
Then the response code should be '200'
When I commit the sandbox
Then I should not get an exception
- When I create a versioned cookbook named 'testcookbook_invalid_empty_except_metadata' versioned '0.1.0' with 'testcookbook_invalid_empty'
+ When I create a cookbook named 'testcookbook_invalid_empty_except_metadata' with only the metadata file
Then I should get a '400 "Bad Request"' exception
diff --git a/features/cookbooks/metadata.feature b/features/cookbooks/metadata.feature
index 17be127b22..454f7624c4 100644
--- a/features/cookbooks/metadata.feature
+++ b/features/cookbooks/metadata.feature
@@ -8,14 +8,13 @@ Feature: Cookbook Metadata
Given a local cookbook repository
When I run the task to generate cookbook metadata
Then the run should exit '0'
- And 'stdout' should have 'Generating metadata for metadata'
- And 'stdout' should have 'Generating metadata for execute_commands'
+ And 'stdout' should have 'Generating Metadata'
And a file named 'cookbooks_dir/cookbooks/metadata/metadata.json' should exist
Scenario: Generate metadata for a specific cookbook
Given a local cookbook repository
When I run the task to generate cookbook metadata for 'metadata'
Then the run should exit '0'
- And 'stdout' should have 'Generating metadata for metadata'
+ And 'stdout' should have 'Generating Metadata'
And a file named 'cookbooks_dir/cookbooks/metadata/metadata.json' should exist
diff --git a/features/steps/cookbook_steps.rb b/features/steps/cookbook_steps.rb
index edf4c12d26..e830d42821 100644
--- a/features/steps/cookbook_steps.rb
+++ b/features/steps/cookbook_steps.rb
@@ -101,8 +101,23 @@ When /^I create a versioned cookbook(?: named '(.*?)')?(?: versioned '(.*?)')? w
begin
self.api_response = rest.put_rest("/cookbooks/#{request_name}/#{request_version}", cookbook)
self.inflated_response = api_response
- rescue
- self.exception = $!
+ rescue => e
+ self.exception = e
+ end
+end
+
+# The argument handling in the above step defn isn't working for me, so dup city.
+# :/
+When "I create a cookbook named '$cookbook_name' with only the metadata file" do |cookbook_name|
+ cookbook = @cookbook_loader_not_uploaded_at_feature_start[cookbook_name.to_sym]
+ raise ArgumentError, "no such cookbook in cookbooks_not_uploaded_at_feature_start: #{cookbook_name}" unless cookbook
+
+ begin
+ self.api_response = rest.put_rest("/cookbooks/#{cookbook_name}/1.0.0", cookbook)
+ self.inflated_response = api_response
+ rescue => e
+ Chef::Log.debug("Caught exception #{e} from HTTP request")
+ self.exception = e
end
end