package hudson.plugins.s3;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class BucketnameTest {

  @Test
  public void testAnythingAfterSlashInBucketNameIsPrependedToObjectName() {

    // Assertions based on the behaviour of toString is maybe fragile but I think 
    // reasonably readable.
    
    assertEquals( "Destination [bucketName=my-bucket-name, objectName=test.txt]", 
        new Destination("my-bucket-name", "test.txt").toString() );
    
    assertEquals( "Destination [bucketName=my-bucket-name, objectName=foo/test.txt]", 
        new Destination("my-bucket-name/foo", "test.txt").toString() );
    
    assertEquals( "Destination [bucketName=my-bucket-name, objectName=foo/baz/test.txt]", 
        new Destination("my-bucket-name/foo/baz", "test.txt").toString() );

    // Unclear if this is the desired behaviour or not:
    assertEquals( "Destination [bucketName=my-bucket-name, objectName=/test.txt]", 
        new Destination("my-bucket-name/", "test.txt").toString() );
  
  }

}

@@ -1028,10 +1028,299 @@
   %0A  %7D%0A%0A
+  @Test%0A  public void testWindowsPathsConvertingToS3CompatiblePaths() %7B%0A    assertEquals(%22Destination %5BbucketName=my-bucket, objectName=with-some/subfolder//path-from/windows.txt%5D%22,%0A            new Destination(%22my-bucket/with-some/subfolder/%22, %22path-from%5C%5Cwindows.txt%22).toString() );%0A  %7D%0A%0A
 %7D%0A

Test to verify changes to Destination in regard to Windows backslash cleaning