filer_multipart_test.go 1.7 KB

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