Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed cookbook upload tests

There was an issue when commiting the sandbox after uploading its
contents. We were sending the is_complete flag as a String when the Chef
Server expected a boolean flag. Fixing the binder fixed the live test.
  • Loading branch information...
commit d09640e86fdea9e3e1a73dd570b0d4b8d66fb4d2 1 parent bbeec9b
@nacx nacx authored
View
2  core/src/main/java/org/jclouds/chef/binders/BindIsCompletedToJsonPayload.java
@@ -34,7 +34,7 @@
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object payload ) {
- super.bindToRequest(request, String.format("{\"is_completed\":\"%s\"}", payload));
+ super.bindToRequest(request, String.format("{\"is_completed\":%s}", payload));
request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
return request;
}
View
2  core/src/test/java/org/jclouds/chef/ChefAsyncClientTest.java
@@ -86,7 +86,7 @@ public void testCommitSandbox() throws SecurityException, NoSuchMethodException,
assertRequestLineEquals(httpRequest,
"PUT http://localhost:4000/sandboxes/0189e76ccc476701d6b374e5a1a27347 HTTP/1.1");
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
- assertPayloadEquals(httpRequest, "{\"is_completed\":\"true\"}", "application/json", false);
+ assertPayloadEquals(httpRequest, "{\"is_completed\":true}", "application/json", false);
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
assertSaxResponseParserClassEquals(method, null);
View
23 core/src/test/java/org/jclouds/chef/internal/BaseChefClientLiveTest.java
@@ -130,11 +130,11 @@ public void testCreateNewCookbook() throws Exception {
}
// create a new cookbook
- CookbookVersion cookbook = new CookbookVersion("test3", "0.0.0");
+ CookbookVersion cookbook = new CookbookVersion(PREFIX, "0.0.0");
cookbook.getRootFiles().add(new Resource(content));
// upload the cookbook to the remote server
- chefClient.updateCookbook("test3", "0.0.0", cookbook);
+ chefClient.updateCookbook(PREFIX, "0.0.0", cookbook);
}
@Test(dependsOnMethods = "testCreateClient")
@@ -168,22 +168,13 @@ public void testListCookbooks() throws Exception {
@Test(dependsOnMethods = "testCreateNewCookbook")
public void testUpdateCookbook() throws Exception {
- for (String cookbook : chefClient.listCookbooks())
- for (String version : chefClient.getVersionsOfCookbook(cookbook)) {
- CookbookVersion cook = chefClient.getCookbook(cookbook, version);
- chefClient.updateCookbook(cookbook, version, cook);
- }
+ CookbookVersion cookbook = chefClient.getCookbook(PREFIX, "0.0.0");
+ assertNotNull(chefClient.updateCookbook(PREFIX, "0.0.0", cookbook));
}
- @Test(dependsOnMethods = {"testCreateNewCookbook", "testUpdateCookbook"}, enabled = false)
- public void testCreateCookbook() throws Exception {
- for (String cookbook : chefClient.listCookbooks())
- for (String version : chefClient.getVersionsOfCookbook(cookbook)) {
- CookbookVersion cook = chefClient.getCookbook(cookbook, version);
- chefClient.deleteCookbook(cookbook, version);
- assert chefClient.getCookbook(cookbook, version) == null : cookbook + version;
- chefClient.updateCookbook(cookbook, version, cook);
- }
+ @Test(dependsOnMethods = {"testCreateNewCookbook", "testUpdateCookbook"})
+ public void testDeleteCookbook() throws Exception {
+ assertNotNull(chefClient.deleteCookbook(PREFIX, "0.0.0"));
}
@Test(expectedExceptions = AuthorizationException.class)
Please sign in to comment.
Something went wrong with that request. Please try again.