Skip to content

Commit

Permalink
updated func test for rabbitmq to auto-del queue
Browse files Browse the repository at this point in the history
  • Loading branch information
dselans committed Sep 14, 2024
1 parent eb9f8a3 commit f04e4bd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions main_functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3012,17 +3012,22 @@ func createRabbitConnection(binary string) string {

func createRabbit(exchangeName, queueName, routingKey string) error {
var err error

// Create exchange
cmd := exec.Command("docker", "exec", "rabbitmq", "rabbitmqadmin", "declare", "exchange", "name="+exchangeName, "type=topic")
_, err = cmd.CombinedOutput()
if err != nil {
return err
}

cmd = exec.Command("docker", "exec", "rabbitmq", "rabbitmqadmin", "declare", "queue", "name="+queueName, "durable=false")
// Create queue
cmd = exec.Command("docker", "exec", "rabbitmq", "rabbitmqadmin", "declare", "queue", "name="+queueName, "durable=false", "auto_delete=true")
_, err = cmd.CombinedOutput()
if err != nil {
return err
}

// Add binding
cmd = exec.Command("docker", "exec", "rabbitmq", "rabbitmqadmin", "declare", "binding", "source="+exchangeName, "destination="+queueName, "routing_key="+routingKey)
_, err = cmd.CombinedOutput()
if err != nil {
Expand All @@ -3032,16 +3037,11 @@ func createRabbit(exchangeName, queueName, routingKey string) error {
}

func deleteRabbit(exchangeName, queueName string) error {
var err error
cmd := exec.Command("docker", "exec", "rabbitmq", "rabbitmqadmin", "delete", "exchange", "name="+exchangeName)
_, err = cmd.CombinedOutput()
if err != nil {
return err
}
cmd = exec.Command("docker", "exec", "rabbitmq", "rabbitmqadmin", "delete", "queue", "name="+queueName)
_, err = cmd.CombinedOutput()
if err != nil {
return err

if _, err := cmd.CombinedOutput(); err != nil {
return errors.Wrap(err, "unable to delete exchange")
}

return nil
}

0 comments on commit f04e4bd

Please sign in to comment.