-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
amqp_test.go
46 lines (38 loc) · 1012 Bytes
/
amqp_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//go:build integration
package amqp_test
import (
"context"
"os"
"testing"
"github.com/italolelis/outboxer"
"github.com/italolelis/outboxer/es/amqp"
amqpraw "github.com/rabbitmq/amqp091-go"
)
func TestAMQP_EventStream(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
endpoint := os.Getenv("ES_DSN")
if endpoint == "" {
endpoint = "amqp://localhost/"
}
conn, err := amqpraw.Dial(endpoint)
if err != nil {
t.Fatalf("failed to connect to amqp: %s", err)
}
defer conn.Close()
es := amqp.NewAMQP(conn)
if err := es.Send(ctx, &outboxer.OutboxMessage{
Payload: []byte("test payload"),
Options: map[string]interface{}{
amqp.ExchangeNameOption: "test",
amqp.ExchangeTypeOption: "topic",
amqp.RoutingKeyOption: "test.send",
amqp.ExchangeDurable: true,
amqp.ExchangeAutoDelete: false,
amqp.ExchangeInternal: false,
amqp.ExchangeNoWait: false,
},
}); err != nil {
t.Fatalf("an error was not expected: %s", err)
}
}