MCPcopy Create free account
hub / github.com/AbelChe/evil_minio / testObjectAPIPutObjectPart

Function testObjectAPIPutObjectPart

cmd/object-api-multipart_test.go:178–315  ·  view source on GitHub ↗

Tests validate correctness of PutObjectPart.

(obj ObjectLayer, instanceType string, t TestErrHandler)

Source from the content-addressed store, hash-verified

176
177// Tests validate correctness of PutObjectPart.
178func testObjectAPIPutObjectPart(obj ObjectLayer, instanceType string, t TestErrHandler) {
179 // Generating cases for which the PutObjectPart fails.
180 bucket := "minio-bucket"
181 object := "minio-object"
182 opts := ObjectOptions{}
183 // Create bucket before intiating NewMultipartUpload.
184 err := obj.MakeBucket(context.Background(), bucket, MakeBucketOptions{})
185 if err != nil {
186 // Failed to create newbucket, abort.
187 t.Fatalf("%s : %s", instanceType, err.Error())
188 }
189 // Initiate Multipart Upload on the above created bucket.
190 res, err := obj.NewMultipartUpload(context.Background(), bucket, object, opts)
191 if err != nil {
192 // Failed to create NewMultipartUpload, abort.
193 t.Fatalf("%s : %s", instanceType, err.Error())
194 }
195 uploadID := res.UploadID
196 // Creating a dummy bucket for tests.
197 err = obj.MakeBucket(context.Background(), "unused-bucket", MakeBucketOptions{})
198 if err != nil {
199 // Failed to create newbucket, abort.
200 t.Fatalf("%s : %s", instanceType, err.Error())
201 }
202
203 // Collection of non-exhaustive PutObjectPart test cases, valid errors
204 // and success responses.
205 testCases := []struct {
206 bucketName string
207 objName string
208 uploadID string
209 PartID int
210 inputReaderData string
211 inputMd5 string
212 inputSHA256 string
213 intputDataSize int64
214 // flag indicating whether the test should pass.
215 shouldPass bool
216 // expected error output.
217 expectedMd5 string
218 expectedError error
219 }{
220 // Test case 1-4.
221 // Cases with invalid bucket name.
222 {bucketName: ".test", objName: "obj", PartID: 1, expectedError: fmt.Errorf("%s", "Bucket not found: .test")},
223 {bucketName: "------", objName: "obj", PartID: 1, expectedError: fmt.Errorf("%s", "Bucket not found: ------")},
224 {
225 bucketName: "$this-is-not-valid-too", objName: "obj", PartID: 1,
226 expectedError: fmt.Errorf("%s", "Bucket not found: $this-is-not-valid-too"),
227 },
228 {bucketName: "a", objName: "obj", PartID: 1, expectedError: fmt.Errorf("%s", "Bucket not found: a")},
229 // Test case - 5.
230 // Case with invalid object names.
231 {bucketName: bucket, PartID: 1, expectedError: fmt.Errorf("%s", "Object name invalid: minio-bucket/")},
232 // Test case - 6.
233 // Valid object and bucket names but non-existent bucket.
234 {bucketName: "abc", objName: "def", PartID: 1, expectedError: fmt.Errorf("%s", "Bucket not found: abc")},
235 // Test Case - 7.

Callers

nothing calls this directly

Calls 5

mustGetPutObjReaderFunction · 0.85
MakeBucketMethod · 0.65
ErrorMethod · 0.65
NewMultipartUploadMethod · 0.65
PutObjectPartMethod · 0.65

Tested by

no test coverage detected