(t *testing.T)
| 59 | } |
| 60 | |
| 61 | func TestWSBasic(t *testing.T) { |
| 62 | sopts := testWSGetDefaultOptions(t, false) |
| 63 | s := RunServerWithOptions(sopts) |
| 64 | defer s.Shutdown() |
| 65 | |
| 66 | url := fmt.Sprintf("ws://127.0.0.1:%d", sopts.Websocket.Port) |
| 67 | nc, err := nats.Connect(url) |
| 68 | if err != nil { |
| 69 | t.Fatalf("Error on connect: %v", err) |
| 70 | } |
| 71 | defer nc.Close() |
| 72 | |
| 73 | sub, err := nc.SubscribeSync("foo") |
| 74 | if err != nil { |
| 75 | t.Fatalf("Error on subscribe: %v", err) |
| 76 | } |
| 77 | |
| 78 | msgs := make([][]byte, 100) |
| 79 | for i := 0; i < len(msgs); i++ { |
| 80 | msg := make([]byte, rand.Intn(70000)) |
| 81 | for j := 0; j < len(msg); j++ { |
| 82 | msg[j] = 'A' + byte(rand.Intn(26)) |
| 83 | } |
| 84 | msgs[i] = msg |
| 85 | } |
| 86 | for i, msg := range msgs { |
| 87 | if err := nc.Publish("foo", msg); err != nil { |
| 88 | t.Fatalf("Error on publish: %v", err) |
| 89 | } |
| 90 | // Make sure that masking does not overwrite user data |
| 91 | if !bytes.Equal(msgs[i], msg) { |
| 92 | t.Fatalf("User content has been changed: %v, got %v", msgs[i], msg) |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | for i := 0; i < len(msgs); i++ { |
| 97 | msg, err := sub.NextMsg(time.Second) |
| 98 | if err != nil { |
| 99 | t.Fatalf("Error getting next message: %v", err) |
| 100 | } |
| 101 | if !bytes.Equal(msgs[i], msg.Data) { |
| 102 | t.Fatalf("Expected message: %v, got %v", msgs[i], msg) |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | func TestWSControlFrames(t *testing.T) { |
| 108 | sopts := testWSGetDefaultOptions(t, false) |
nothing calls this directly
no test coverage detected