-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpubsub_test.go
More file actions
45 lines (42 loc) · 1.17 KB
/
Copy pathpubsub_test.go
File metadata and controls
45 lines (42 loc) · 1.17 KB
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
package amqp10
import (
"context"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/ThreeDotsLabs/watermill/pubsub/tests"
"github.com/stretchr/testify/require"
"log/slog"
"os"
"testing"
)
func TestPubSub(t *testing.T) {
slogOpts := &slog.HandlerOptions{}
slogOpts.Level = slog.LevelDebug
handler := slog.NewTextHandler(os.Stdout, slogOpts)
slog.SetDefault(slog.New(handler))
tests.TestPubSub(t, tests.Features{
Persistent: true,
RestartServiceCommand: []string{"podman-compose", "-f", "../../compose.yaml", "restart"},
}, constructor, nil)
}
func constructor(t *testing.T) (message.Publisher, message.Subscriber) {
publishConfig := PublishConfig{
Capabilities: []string{"queue"},
Durable: true,
}
subscribeConfig := SubscribeConfig{
Capabilities: []string{"queue"},
Durable: true,
}
config := Config{
Publish: publishConfig,
Subscribe: subscribeConfig,
}
ctx := context.TODO()
conn, err := NewConnection(ctx, config)
require.NoError(t, err)
pub, err := NewPublisherWithConnection(ctx, config, conn)
require.NoError(t, err)
sub, err := NewSubscriberWithConnection(ctx, config, conn)
require.NoError(t, err)
return pub, sub
}