(t *testing.T)
| 220 | } |
| 221 | |
| 222 | func TestDispatchSubscribe(t *testing.T) { |
| 223 | uid := types.Uid(1) |
| 224 | s := test_makeSession(uid) |
| 225 | wg := sync.WaitGroup{} |
| 226 | r := responses{} |
| 227 | wg.Add(1) |
| 228 | go s.testWriteLoop(&r, &wg) |
| 229 | |
| 230 | hub := &Hub{ |
| 231 | join: make(chan *ClientComMessage, 10), |
| 232 | } |
| 233 | globals.hub = hub |
| 234 | |
| 235 | defer func() { |
| 236 | globals.hub = nil |
| 237 | }() |
| 238 | |
| 239 | msg := &ClientComMessage{ |
| 240 | Sub: &MsgClientSub{ |
| 241 | Id: "123", |
| 242 | Topic: "me", |
| 243 | Get: &MsgGetQuery{ |
| 244 | What: "sub desc tags cred", |
| 245 | }, |
| 246 | }, |
| 247 | } |
| 248 | |
| 249 | s.dispatch(msg) |
| 250 | close(s.send) |
| 251 | wg.Wait() |
| 252 | |
| 253 | // Check we've routed the join request via the hub. |
| 254 | if len(r.messages) != 0 { |
| 255 | t.Errorf("responses: expected 0, received %d.", len(r.messages)) |
| 256 | } |
| 257 | if len(hub.join) == 1 { |
| 258 | join := <-hub.join |
| 259 | if join.sess != s { |
| 260 | t.Error("Hub.join request: sess field expected to be the session under test.") |
| 261 | } |
| 262 | if join != msg { |
| 263 | t.Error("Hub.join request: subscribe message expected to be the original subscribe message.") |
| 264 | } |
| 265 | } else { |
| 266 | t.Errorf("Hub join messages: expected 1, received %d.", len(hub.join)) |
| 267 | } |
| 268 | s.inflightReqs.Done() |
| 269 | } |
| 270 | |
| 271 | func TestDispatchAlreadySubscribed(t *testing.T) { |
| 272 | uid := types.Uid(1) |
nothing calls this directly
no test coverage detected
searching dependent graphs…