|
|
@ -54,7 +54,7 @@ func TestGroupReceiver_Close(t *testing.T) { |
|
|
|
defer mc.Finish() |
|
|
|
defer mc.Finish() |
|
|
|
sub := mock.NewMockSubscription(mc) |
|
|
|
sub := mock.NewMockSubscription(mc) |
|
|
|
sub.EXPECT().Cancel() |
|
|
|
sub.EXPECT().Cancel() |
|
|
|
receiver := GroupReceiver{sub: sub} |
|
|
|
receiver := GroupReceiverImpl{sub: sub} |
|
|
|
if err := receiver.Close(); err != nil { |
|
|
|
if err := receiver.Close(); err != nil { |
|
|
|
t.Errorf("expected no error but got %v", err) |
|
|
|
t.Errorf("expected no error but got %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -75,7 +75,7 @@ func TestGroupReceiver_Receive(t *testing.T) { |
|
|
|
sub.EXPECT().Next(ctx).Return(pubsubMessage("DEF", []byte{4, 5, 6}), nil), |
|
|
|
sub.EXPECT().Next(ctx).Return(pubsubMessage("DEF", []byte{4, 5, 6}), nil), |
|
|
|
sub.EXPECT().Next(ctx).Return(nil, errors.New("FIAL")), |
|
|
|
sub.EXPECT().Next(ctx).Return(nil, errors.New("FIAL")), |
|
|
|
) |
|
|
|
) |
|
|
|
receiver := GroupReceiver{sub: sub} |
|
|
|
receiver := GroupReceiverImpl{sub: sub} |
|
|
|
verify := func(sender peer.ID, msg []byte, shouldError bool) { |
|
|
|
verify := func(sender peer.ID, msg []byte, shouldError bool) { |
|
|
|
gotMsg, gotSender, err := receiver.Receive(ctx) |
|
|
|
gotMsg, gotSender, err := receiver.Receive(ctx) |
|
|
|
if (err != nil) != shouldError { |
|
|
|
if (err != nil) != shouldError { |
|
|
@ -106,8 +106,8 @@ func TestHostV2_GroupReceiver(t *testing.T) { |
|
|
|
pubsub.EXPECT().Subscribe("ABC").Return(sub, nil) |
|
|
|
pubsub.EXPECT().Subscribe("ABC").Return(sub, nil) |
|
|
|
host := &HostV2{pubsub: pubsub} |
|
|
|
host := &HostV2{pubsub: pubsub} |
|
|
|
gotReceiver, err := host.GroupReceiver("ABC") |
|
|
|
gotReceiver, err := host.GroupReceiver("ABC") |
|
|
|
if r, ok := gotReceiver.(*GroupReceiver); !ok { |
|
|
|
if r, ok := gotReceiver.(*GroupReceiverImpl); !ok { |
|
|
|
t.Errorf("expected a hostv2 GroupReceiver; got %v", gotReceiver) |
|
|
|
t.Errorf("expected a hostv2 GroupReceiverImpl; got %v", gotReceiver) |
|
|
|
} else if r.sub != sub { |
|
|
|
} else if r.sub != sub { |
|
|
|
t.Errorf("unexpected subscriber %v", r.sub) |
|
|
|
t.Errorf("unexpected subscriber %v", r.sub) |
|
|
|
} |
|
|
|
} |
|
|
@ -123,7 +123,7 @@ func TestHostV2_GroupReceiver(t *testing.T) { |
|
|
|
host := &HostV2{pubsub: pubsub} |
|
|
|
host := &HostV2{pubsub: pubsub} |
|
|
|
gotReceiver, err := host.GroupReceiver("ABC") |
|
|
|
gotReceiver, err := host.GroupReceiver("ABC") |
|
|
|
if gotReceiver != nil { |
|
|
|
if gotReceiver != nil { |
|
|
|
t.Errorf("expected a nil hostv2 GroupReceiver; got %v", gotReceiver) |
|
|
|
t.Errorf("expected a nil hostv2 GroupReceiverImpl; got %v", gotReceiver) |
|
|
|
} |
|
|
|
} |
|
|
|
if err == nil { |
|
|
|
if err == nil { |
|
|
|
t.Error("expected an error; got none") |
|
|
|
t.Error("expected an error; got none") |
|
|
|