feat: improve group member events and push delivery
This commit is contained in:
@@ -564,6 +564,39 @@ func TestDispatchAlreadySubscribed(t *testing.T) {
|
||||
verifyResponseCodes(&r, []int{http.StatusNotModified}, t)
|
||||
}
|
||||
|
||||
func TestSubscribeP2PUserAliasReachesTopic(t *testing.T) {
|
||||
oldHub := globals.hub
|
||||
globals.hub = &Hub{join: make(chan *ClientComMessage, 1)}
|
||||
t.Cleanup(func() { globals.hub = oldHub })
|
||||
|
||||
self := types.Uid(1)
|
||||
peer := types.Uid(2)
|
||||
canonical := self.P2PName(peer)
|
||||
s := test_makeSession(self)
|
||||
s.subs = map[string]*Subscription{canonical: {}}
|
||||
msg := &ClientComMessage{
|
||||
Sub: &MsgClientSub{Id: "alias-sub", Topic: peer.UserId()},
|
||||
Id: "alias-sub",
|
||||
Original: peer.UserId(),
|
||||
AsUser: self.UserId(),
|
||||
TenantID: s.tenantID,
|
||||
Timestamp: types.TimeNow(),
|
||||
sess: s,
|
||||
}
|
||||
|
||||
s.subscribe(msg)
|
||||
|
||||
select {
|
||||
case routed := <-globals.hub.join:
|
||||
if routed != msg || routed.RcptTo != canonical {
|
||||
t.Fatalf("unexpected alias subscription route: %#v", routed)
|
||||
}
|
||||
s.inflightReqs.Done()
|
||||
default:
|
||||
t.Fatal("p2p user alias was incorrectly handled as an already-subscribed topic")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDispatchSubscribeJoinChannelFull(t *testing.T) {
|
||||
uid := types.Uid(1)
|
||||
s := test_makeSession(uid)
|
||||
|
||||
Reference in New Issue
Block a user