summaryrefslogtreecommitdiff
path: root/srv/src/chat
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-05-08 16:36:08 -0600
committerBrian Picciano <mediocregopher@gmail.com>2022-05-08 16:36:08 -0600
commitddb126db1709b1c7679b8370b508639991387bf0 (patch)
tree900de6adc1590961c547f447e973d78a306b3ce8 /srv/src/chat
parent450136a0c0dbd675a87d6af54f7aba5c9d079c21 (diff)
Move radix config into cfg, use that for integration tests
Diffstat (limited to 'srv/src/chat')
-rw-r--r--srv/src/chat/chat_it_test.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/srv/src/chat/chat_it_test.go b/srv/src/chat/chat_it_test.go
index 1767d88..b0d4431 100644
--- a/srv/src/chat/chat_it_test.go
+++ b/srv/src/chat/chat_it_test.go
@@ -1,4 +1,5 @@
//go:build integration
+// +build integration
package chat
@@ -9,6 +10,7 @@ import (
"time"
"github.com/google/uuid"
+ cfgpkg "github.com/mediocregopher/blog.mediocregopher.com/srv/cfg"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog"
"github.com/mediocregopher/radix/v4"
"github.com/stretchr/testify/assert"
@@ -44,16 +46,25 @@ func (h *roomTestHarness) newMsg(t *testing.T) Message {
}
func newRoomTestHarness(t *testing.T) *roomTestHarness {
+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
t.Cleanup(cancel)
- redis, err := radix.Dial(ctx, "tcp", "127.0.0.1:6379")
- assert.NoError(t, err)
- t.Cleanup(func() { redis.Close() })
+ cfg := cfgpkg.NewBlogCfg(cfgpkg.Params{
+ Args: []string{}, // prevents the test process args from interfering
+ })
+
+ var radixClient cfgpkg.RadixClient
+ radixClient.SetupCfg(cfg)
+ t.Cleanup(func() { radixClient.Close() })
+
+ if err := cfg.Init(ctx); err != nil {
+ t.Fatal(err)
+ }
roomParams := RoomParams{
Logger: mlog.NewLogger(nil),
- Redis: redis,
+ Redis: radixClient.Client,
ID: uuid.New().String(),
MaxMessages: roomTestHarnessMaxMsgs,
}
@@ -63,7 +74,7 @@ func newRoomTestHarness(t *testing.T) *roomTestHarness {
assert.NoError(t, err)
t.Cleanup(func() {
- err := redis.Do(context.Background(), radix.Cmd(
+ err := radixClient.Client.Do(context.Background(), radix.Cmd(
nil, "DEL", roomParams.streamKey(),
))
assert.NoError(t, err)