MCPcopy
hub / github.com/minio/minio-go / testGetObjectModified

Function testGetObjectModified

functional_tests.go:8186–8262  ·  view source on GitHub ↗

Test for validating GetObject Reader* methods functioning when the object is modified in the object store.

()

Source from the content-addressed store, hash-verified

8184// Test for validating GetObject Reader* methods functioning when the
8185// object is modified in the object store.
8186func testGetObjectModified() {
8187 // initialize logging params
8188 startTime := time.Now()
8189 testName := getFuncName()
8190 function := "GetObject(bucketName, objectName)"
8191 args := map[string]interface{}{}
8192
8193 c, err := NewClient(ClientConfig{})
8194 if err != nil {
8195 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
8196 return
8197 }
8198
8199 // Make a new bucket.
8200 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
8201 args["bucketName"] = bucketName
8202
8203 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"})
8204 if err != nil {
8205 logError(testName, function, args, startTime, "", "MakeBucket failed", err)
8206 return
8207 }
8208
8209 defer cleanupBucket(bucketName, c)
8210
8211 // Upload an object.
8212 objectName := "myobject"
8213 args["objectName"] = objectName
8214 content := "helloworld"
8215 _, err = c.PutObject(context.Background(), bucketName, objectName, strings.NewReader(content), int64(len(content)), minio.PutObjectOptions{ContentType: "application/text"})
8216 if err != nil {
8217 logError(testName, function, args, startTime, "", "Failed to upload "+objectName+", to bucket "+bucketName, err)
8218 return
8219 }
8220
8221 defer c.RemoveObject(context.Background(), bucketName, objectName, minio.RemoveObjectOptions{})
8222
8223 reader, err := c.GetObject(context.Background(), bucketName, objectName, minio.GetObjectOptions{})
8224 if err != nil {
8225 logError(testName, function, args, startTime, "", "Failed to GetObject "+objectName+", from bucket "+bucketName, err)
8226 return
8227 }
8228 defer reader.Close()
8229
8230 // Read a few bytes of the object.
8231 b := make([]byte, 5)
8232 n, err := reader.ReadAt(b, 0)
8233 if err != nil {
8234 logError(testName, function, args, startTime, "", "Failed to read object "+objectName+", from bucket "+bucketName+" at an offset", err)
8235 return
8236 }
8237
8238 // Upload different contents to the same object while object is being read.
8239 newContent := "goodbyeworld"
8240 _, err = c.PutObject(context.Background(), bucketName, objectName, strings.NewReader(newContent), int64(len(newContent)), minio.PutObjectOptions{ContentType: "application/text"})
8241 if err != nil {
8242 logError(testName, function, args, startTime, "", "Failed to upload "+objectName+", to bucket "+bucketName, err)
8243 return

Callers 1

mainFunction · 0.85

Calls 14

MakeBucketMethod · 0.95
PutObjectMethod · 0.95
RemoveObjectMethod · 0.95
GetObjectMethod · 0.95
getFuncNameFunction · 0.85
NewClientFunction · 0.85
logErrorFunction · 0.85
cleanupBucketFunction · 0.85
logSuccessFunction · 0.85
ReadAtMethod · 0.80
StatMethod · 0.80
randStringFunction · 0.70

Tested by

no test coverage detected