(t *testing.T)
| 363 | } |
| 364 | |
| 365 | func TestWebSocketCreateDestroyTopic(t *testing.T) { |
| 366 | ensureServer() |
| 367 | token := signUpAndGetToken(t) |
| 368 | |
| 369 | ws := dialWS(t, token) |
| 370 | defer ws.Close() |
| 371 | |
| 372 | topicName := fmt.Sprintf("test-topic-%d", time.Now().UnixNano()) |
| 373 | |
| 374 | // create topic |
| 375 | id := nextReqId() |
| 376 | sendJSON(t, ws, wsPayload{ |
| 377 | Id: id, |
| 378 | Method: "create-topicName", |
| 379 | Payload: map[string]interface{}{"name": topicName}, |
| 380 | }) |
| 381 | |
| 382 | msg := recvJSON(t, ws, 5*time.Second) |
| 383 | if msg.Type != "response" || msg.Ok == nil || !*msg.Ok { |
| 384 | t.Errorf("expected successful create response, got type=%q ok=%v error=%q", msg.Type, msg.Ok, msg.Error) |
| 385 | } |
| 386 | |
| 387 | // destroy it |
| 388 | sendJSON(t, ws, wsPayload{ |
| 389 | Id: nextReqId(), |
| 390 | Method: "destroy-topicName", |
| 391 | Payload: map[string]interface{}{"name": topicName}, |
| 392 | }) |
| 393 | msg = recvJSON(t, ws, 5*time.Second) |
| 394 | if msg.Type != "response" || msg.Ok == nil || !*msg.Ok { |
| 395 | t.Errorf("expected successful destroy response, got type=%q ok=%v error=%q", msg.Type, msg.Ok, msg.Error) |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | func TestWebSocketDestroySystemTopicError(t *testing.T) { |
| 400 | ensureServer() |
nothing calls this directly
no test coverage detected