(t *testing.T)
| 1254 | } |
| 1255 | |
| 1256 | func TestSyncSubscriptionPendingDrain(t *testing.T) { |
| 1257 | s := RunDefaultServer() |
| 1258 | defer s.Shutdown() |
| 1259 | |
| 1260 | nc := NewDefaultConnection(t) |
| 1261 | defer nc.Close() |
| 1262 | |
| 1263 | // Send some messages to ourselves. |
| 1264 | total := 100 |
| 1265 | msg := []byte("0123456789") |
| 1266 | |
| 1267 | sub, _ := nc.SubscribeSync("foo") |
| 1268 | defer sub.Unsubscribe() |
| 1269 | |
| 1270 | for range total { |
| 1271 | nc.Publish("foo", msg) |
| 1272 | } |
| 1273 | nc.Flush() |
| 1274 | |
| 1275 | // Wait for all delivered. |
| 1276 | for d, _ := sub.Delivered(); d != int64(total); d, _ = sub.Delivered() { |
| 1277 | sub.NextMsg(10 * time.Millisecond) |
| 1278 | } |
| 1279 | |
| 1280 | m, b, _ := sub.Pending() |
| 1281 | if m != 0 { |
| 1282 | t.Fatalf("Expected msgs of 0, got %d", m) |
| 1283 | } |
| 1284 | if b != 0 { |
| 1285 | t.Fatalf("Expected bytes of 0, got %d", b) |
| 1286 | } |
| 1287 | |
| 1288 | sub.Unsubscribe() |
| 1289 | if _, err := sub.Delivered(); err == nil { |
| 1290 | t.Fatal("Calling Delivered() on closed subscription should fail") |
| 1291 | } |
| 1292 | } |
| 1293 | |
| 1294 | func TestSyncSubscriptionPending(t *testing.T) { |
| 1295 | s := RunDefaultServer() |
nothing calls this directly
no test coverage detected