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

Function testBucketNotification

functional_tests.go:7429–7517  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7427}
7428
7429func testBucketNotification() {
7430 // initialize logging params
7431 startTime := time.Now()
7432 testName := getFuncName()
7433 function := "SetBucketNotification(bucketName)"
7434 args := map[string]interface{}{
7435 "bucketName": "",
7436 }
7437
7438 if os.Getenv("NOTIFY_BUCKET") == "" ||
7439 os.Getenv("NOTIFY_SERVICE") == "" ||
7440 os.Getenv("NOTIFY_REGION") == "" ||
7441 os.Getenv("NOTIFY_ACCOUNTID") == "" ||
7442 os.Getenv("NOTIFY_RESOURCE") == "" {
7443 logIgnored(testName, function, args, startTime, "Skipped notification test as it is not configured")
7444 return
7445 }
7446
7447 c, err := NewClient(ClientConfig{})
7448 if err != nil {
7449 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
7450 return
7451 }
7452
7453 bucketName := os.Getenv("NOTIFY_BUCKET")
7454 args["bucketName"] = bucketName
7455
7456 topicArn := notification.NewArn("aws", os.Getenv("NOTIFY_SERVICE"), os.Getenv("NOTIFY_REGION"), os.Getenv("NOTIFY_ACCOUNTID"), os.Getenv("NOTIFY_RESOURCE"))
7457 queueArn := notification.NewArn("aws", "dummy-service", "dummy-region", "dummy-accountid", "dummy-resource")
7458
7459 topicConfig := notification.NewConfig(topicArn)
7460 topicConfig.AddEvents(notification.ObjectCreatedAll, notification.ObjectRemovedAll)
7461 topicConfig.AddFilterSuffix("jpg")
7462
7463 queueConfig := notification.NewConfig(queueArn)
7464 queueConfig.AddEvents(notification.ObjectCreatedAll)
7465 queueConfig.AddFilterPrefix("photos/")
7466
7467 config := notification.Configuration{}
7468 config.AddTopic(topicConfig)
7469
7470 // Add the same topicConfig again, should have no effect
7471 // because it is duplicated
7472 config.AddTopic(topicConfig)
7473 if len(config.TopicConfigs) != 1 {
7474 logError(testName, function, args, startTime, "", "Duplicate entry added", err)
7475 return
7476 }
7477
7478 // Add and remove a queue config
7479 config.AddQueue(queueConfig)
7480 config.RemoveQueueByArn(queueArn)
7481
7482 err = c.SetBucketNotification(context.Background(), bucketName, config)
7483 if err != nil {
7484 logError(testName, function, args, startTime, "", "SetBucketNotification failed", err)
7485 return
7486 }

Callers 1

mainFunction · 0.85

Calls 15

AddEventsMethod · 0.95
AddFilterSuffixMethod · 0.95
AddFilterPrefixMethod · 0.95
AddTopicMethod · 0.95
AddQueueMethod · 0.95
RemoveQueueByArnMethod · 0.95
SetBucketNotificationMethod · 0.95
GetBucketNotificationMethod · 0.95
NewArnFunction · 0.92
NewConfigFunction · 0.92
getFuncNameFunction · 0.85

Tested by

no test coverage detected