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

Method TestEmptyObject

cmd/server_test.go:723–766  ·  view source on GitHub ↗

TestEmptyObject - Asserts the response for operation on a 0 byte object.

(c *check)

Source from the content-addressed store, hash-verified

721
722// TestEmptyObject - Asserts the response for operation on a 0 byte object.
723func (s *TestSuiteCommon) TestEmptyObject(c *check) {
724 // generate a random bucket name.
725 bucketName := getRandomBucketName()
726 // HTTP request to create the bucket.
727 request, err := newTestSignedRequest(http.MethodPut, getMakeBucketURL(s.endPoint, bucketName),
728 0, nil, s.accessKey, s.secretKey, s.signer)
729 c.Assert(err, nil)
730
731 // execute the http request.
732 response, err := s.client.Do(request)
733 c.Assert(err, nil)
734 // assert the http response status code.
735 c.Assert(response.StatusCode, http.StatusOK)
736
737 objectName := "test-object"
738 // construct http request for uploading the object.
739 request, err = newTestSignedRequest(http.MethodPut, getPutObjectURL(s.endPoint, bucketName, objectName),
740 0, nil, s.accessKey, s.secretKey, s.signer)
741 c.Assert(err, nil)
742
743 // execute the upload request.
744 response, err = s.client.Do(request)
745 c.Assert(err, nil)
746 // assert the http response.
747 c.Assert(response.StatusCode, http.StatusOK)
748
749 // make HTTP request to fetch the object.
750 request, err = newTestSignedRequest(http.MethodGet, getGetObjectURL(s.endPoint, bucketName, objectName),
751 0, nil, s.accessKey, s.secretKey, s.signer)
752 c.Assert(err, nil)
753
754 // execute the http request to fetch object.
755 response, err = s.client.Do(request)
756 c.Assert(err, nil)
757 // assert the http response status code.
758 c.Assert(response.StatusCode, http.StatusOK)
759
760 var buffer bytes.Buffer
761 // extract the body of the response.
762 responseBody, err := io.ReadAll(response.Body)
763 c.Assert(err, nil)
764 // assert the http response body content.
765 c.Assert(true, bytes.Equal(responseBody, buffer.Bytes()))
766}
767
768func (s *TestSuiteCommon) TestBucket(c *check) {
769 // generate a random bucket name.

Callers 1

runAllTestsFunction · 0.80

Calls 9

getRandomBucketNameFunction · 0.85
newTestSignedRequestFunction · 0.85
getMakeBucketURLFunction · 0.85
getPutObjectURLFunction · 0.85
getGetObjectURLFunction · 0.85
AssertMethod · 0.80
BytesMethod · 0.80
ReadAllMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected