Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Jul 11, 2024
1 parent 2bc1734 commit 066426d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,26 @@ func TestClientSubscribeValidateErrors(t *testing.T) {
require.Equal(t, DisconnectBadRequest, err)
}

func TestClientSubscribeNoChannelContext(t *testing.T) {
t.Parallel()
node := defaultTestNode()
defer func() { _ = node.Shutdown(context.Background()) }()
transport := newTestTransport(func() {})
transport.sink = make(chan []byte, 100)
ctx := context.Background()
newCtx := SetCredentials(ctx, &Credentials{UserID: "42"})
client, _ := newClient(newCtx, node, transport)

connectClientV2(t, client)

rwWrapper := testReplyWriterWrapper()

subCtx := client.subscribeCmd(&protocol.SubscribeRequest{
Channel: "test",
}, SubscribeReply{}, &protocol.Command{}, false, time.Now(), rwWrapper.rw)
require.Equal(t, &DisconnectServerError, subCtx.disconnect)
}

func TestClientSubscribeReceivePublication(t *testing.T) {
t.Parallel()
node := defaultTestNode()
Expand All @@ -797,6 +817,7 @@ func TestClientSubscribeReceivePublication(t *testing.T) {

rwWrapper := testReplyWriterWrapper()

client.channels["test"] = ChannelContext{}
subCtx := client.subscribeCmd(&protocol.SubscribeRequest{
Channel: "test",
}, SubscribeReply{}, &protocol.Command{}, false, time.Now(), rwWrapper.rw)
Expand Down Expand Up @@ -837,6 +858,7 @@ func TestClientSubscribeReceivePublicationWithOffset(t *testing.T) {

rwWrapper := testReplyWriterWrapper()

client.channels["test"] = ChannelContext{}
subCtx := client.subscribeCmd(&protocol.SubscribeRequest{
Channel: "test",
}, SubscribeReply{}, &protocol.Command{}, false, time.Now(), rwWrapper.rw)
Expand Down Expand Up @@ -3102,6 +3124,7 @@ func TestClientTransportWriteError(t *testing.T) {
connectClientV2(t, client)

rwWrapper := testReplyWriterWrapper()
client.channels["test"] = ChannelContext{}
subCtx := client.subscribeCmd(&protocol.SubscribeRequest{
Channel: "test",
}, SubscribeReply{}, &protocol.Command{}, false, time.Time{}, rwWrapper.rw)
Expand Down
1 change: 1 addition & 0 deletions node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ func newFakeConn(b testing.TB, node *Node, channel string, protoType ProtocolTyp
client, _ := newClient(newCtx, node, transport)
connectClientV2(b, client)
rwWrapper := testReplyWriterWrapper()
client.channels[channel] = ChannelContext{}
subCtx := client.subscribeCmd(&protocol.SubscribeRequest{
Channel: channel,
}, SubscribeReply{}, &protocol.Command{}, false, time.Now(), rwWrapper.rw)
Expand Down

0 comments on commit 066426d

Please sign in to comment.