(t *testing.T)
| 30 | ) |
| 31 | |
| 32 | func Test200MultipartUploadWithSpaces(t *testing.T) { |
| 33 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 34 | w.Write([]byte(`<?xml version="1.0" encoding="UTF-8"?>`)) |
| 35 | w.(http.Flusher).Flush() |
| 36 | for i := 0; i < 10; i++ { |
| 37 | time.Sleep(time.Second) |
| 38 | w.Write([]byte(" ")) |
| 39 | w.(http.Flusher).Flush() |
| 40 | } |
| 41 | |
| 42 | w.Write([]byte(`<CompleteMultipartUploadResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Location>http://random/bucket/object</Location><Bucket>bucket</Bucket><Key>object</Key><ETag>"2b3ffa539769372e2df9553358fe26b2-2"</ETag></CompleteMultipartUploadResult>`)) |
| 43 | })) |
| 44 | |
| 45 | srv, err := url.Parse(ts.URL) |
| 46 | if err != nil { |
| 47 | t.Fatal(err) |
| 48 | } |
| 49 | |
| 50 | // Instantiate new minio client object. |
| 51 | core, err := NewCore( |
| 52 | srv.Host, |
| 53 | &Options{ |
| 54 | Creds: credentials.NewStaticV4("foo", "foo12345", ""), |
| 55 | Secure: srv.Scheme == "https", |
| 56 | }) |
| 57 | if err != nil { |
| 58 | t.Fatal("Error:", err) |
| 59 | } |
| 60 | |
| 61 | parts := []CompletePart{ |
| 62 | {PartNumber: 1, ETag: "b386a859d8a22ff986c0b1252be34658"}, |
| 63 | {PartNumber: 2, ETag: "78c577a580bbbba92845789cda1fa932"}, |
| 64 | } |
| 65 | |
| 66 | foundUploadInfo, err := core.CompleteMultipartUpload(context.Background(), |
| 67 | "bucket", |
| 68 | "object", |
| 69 | "jY1M2U5NWMtZGY2OC00ZjYyLTljZGYtYmZlOWEzODM3MDMwLjlmZWY5OGNlLWQ1Y2EtNDgwMC04N2Y4LWZkNTNkMDM4ZDdiMXgxNzQ4NjA0NzI0NzE4NjU3MTY3", |
| 70 | parts, |
| 71 | PutObjectOptions{}, |
| 72 | ) |
| 73 | if err != nil { |
| 74 | t.Fatal("Error:", err) |
| 75 | } |
| 76 | |
| 77 | expectedUploadInfo := UploadInfo{ |
| 78 | Bucket: "bucket", |
| 79 | Key: "object", |
| 80 | ETag: "2b3ffa539769372e2df9553358fe26b2-2", |
| 81 | Location: "http://random/bucket/object", |
| 82 | } |
| 83 | |
| 84 | if foundUploadInfo != expectedUploadInfo { |
| 85 | t.Fatalf("Unexpected upload info, expected: `%v`, found: `%v`", expectedUploadInfo, foundUploadInfo) |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | func Test200MultipartUploadWithError(t *testing.T) { |
nothing calls this directly
no test coverage detected