filer_multipart_test.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package s3api
  2. import (
  3. "github.com/aws/aws-sdk-go/aws"
  4. "github.com/aws/aws-sdk-go/service/s3"
  5. "testing"
  6. "time"
  7. )
  8. func TestInitiateMultipartUploadResult(t *testing.T) {
  9. expected := `<?xml version="1.0" encoding="UTF-8"?>
  10. <InitiateMultipartUploadResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Bucket>example-bucket</Bucket><Key>example-object</Key><UploadId>VXBsb2FkIElEIGZvciA2aWWpbmcncyBteS1tb3ZpZS5tMnRzIHVwbG9hZA</UploadId></InitiateMultipartUploadResult>`
  11. response := &InitiateMultipartUploadResult{
  12. CreateMultipartUploadOutput: s3.CreateMultipartUploadOutput{
  13. Bucket: aws.String("example-bucket"),
  14. Key: aws.String("example-object"),
  15. UploadId: aws.String("VXBsb2FkIElEIGZvciA2aWWpbmcncyBteS1tb3ZpZS5tMnRzIHVwbG9hZA"),
  16. },
  17. }
  18. encoded := string(encodeResponse(response))
  19. if encoded != expected {
  20. t.Errorf("unexpected output: %s\nexpecting:%s", encoded, expected)
  21. }
  22. }
  23. func TestListPartsResult(t *testing.T) {
  24. expected := `<?xml version="1.0" encoding="UTF-8"?>
  25. <ListPartsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Part><ETag>&#34;12345678&#34;</ETag><LastModified>1970-01-01T00:00:00Z</LastModified><PartNumber>1</PartNumber><Size>123</Size></Part></ListPartsResult>`
  26. response := &ListPartsResult{
  27. Part: []*s3.Part{
  28. {
  29. PartNumber: aws.Int64(int64(1)),
  30. LastModified: aws.Time(time.Unix(0, 0).UTC()),
  31. Size: aws.Int64(int64(123)),
  32. ETag: aws.String("\"12345678\""),
  33. },
  34. },
  35. }
  36. encoded := string(encodeResponse(response))
  37. if encoded != expected {
  38. t.Errorf("unexpected output: %s\nexpecting:%s", encoded, expected)
  39. }
  40. }