feat(tenant): 隔离客服通知文件与后台任务
This commit is contained in:
@@ -30,3 +30,28 @@ func TestDisconnectUserClosesAllConnections(t *testing.T) {
|
||||
t.Fatalf("online admin connection count = %d, want 1", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotifyAllAdminsRespectsTenantAndPlatformScope(t *testing.T) {
|
||||
hub := NewHub(nil)
|
||||
tenantA := hub.SubscribeAdmin(1, 101, false)
|
||||
tenantB := hub.SubscribeAdmin(2, 202, false)
|
||||
platform := hub.SubscribeAdmin(3, 101, true)
|
||||
|
||||
hub.NotifyAllAdmins(&ChatEvent{
|
||||
Type: "conversation_updated",
|
||||
ConversationID: 9,
|
||||
TenantIDs: []uint64{101},
|
||||
})
|
||||
|
||||
if got := <-tenantA; got.ConversationID != 9 {
|
||||
t.Fatalf("tenant A conversation = %d", got.ConversationID)
|
||||
}
|
||||
if got := <-platform; got.ConversationID != 9 {
|
||||
t.Fatalf("platform conversation = %d", got.ConversationID)
|
||||
}
|
||||
select {
|
||||
case event := <-tenantB:
|
||||
t.Fatalf("tenant B received cross-tenant event: %+v", event)
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user