> @@ -132,6 +132,41 @@ void testVirtualMachine() {
>     }
>  
>     @Test
> +   void testAddStorageResourceWhenNameIsLongerThan24Chars() {
> +      String name = "thishasmorethan24characters";
> +      DeploymentTemplateBuilder builder = 
> getMockDeploymentTemplateBuilderWithEmptyOptions(name);
> +
> +      DeploymentBody deploymentBody = builder.getDeploymentTemplate();
> +      
> assertTrue(Iterables.contains(deploymentBody.template().variables().keySet(), 
> "storageAccountName"));
> +      String storageAccountName = 
> deploymentBody.template().variables().get("storageAccountName");
> +      assertEquals(storageAccountName.length(), 24);
> +      assertEquals(storageAccountName.substring(0, 10), 
> name.replaceAll("[^a-z0-9]", "").substring(0, 10));
> +      assertEquals(storageAccountName.substring(storageAccountName.length() 
> - 10, storageAccountName.length()), name.replaceAll("[^a-z0-9]", 
> "").substring(name.length() - 10, name.length()));

Tests should not replicate the business logic (or they aren't actually testing 
that it produces the expected value; if the business logic is broken, the test 
is broken too).
Instead, make assertions against concrete values. Assert that the value is a 
concrete one, or starts with the expected String and has N prefix and N suffix 
characters, etc.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/301/files/952392e682c37a0fd7bbe6513296faec3c49c719#r70884679

Reply via email to