(t *testing.T)
| 1311 | } |
| 1312 | |
| 1313 | func TestZscan(t *testing.T) { |
| 1314 | server.Clear() |
| 1315 | c, err := proto.Dial(server.Addr()) |
| 1316 | ok(t, err) |
| 1317 | defer c.Close() |
| 1318 | s := server.Direct() |
| 1319 | |
| 1320 | // We cheat with zscan. It always returns everything. |
| 1321 | |
| 1322 | s.ZAdd("h", 1.0, "field1") |
| 1323 | s.ZAdd("h", 2.0, "field2") |
| 1324 | |
| 1325 | // No problem |
| 1326 | mustDo(t, c, |
| 1327 | "ZSCAN", "h", "0", |
| 1328 | proto.Array( |
| 1329 | proto.String("0"), |
| 1330 | proto.Array( |
| 1331 | proto.String("field1"), |
| 1332 | proto.String("1"), |
| 1333 | proto.String("field2"), |
| 1334 | proto.String("2"), |
| 1335 | ), |
| 1336 | ), |
| 1337 | ) |
| 1338 | |
| 1339 | // Invalid cursor |
| 1340 | mustDo(t, c, |
| 1341 | "ZSCAN", "h", "42", |
| 1342 | proto.Array( |
| 1343 | proto.String("0"), |
| 1344 | proto.Array(), |
| 1345 | ), |
| 1346 | ) |
| 1347 | |
| 1348 | // COUNT (ignored) |
| 1349 | mustDo(t, c, |
| 1350 | "ZSCAN", "h", "0", "COUNT", "200", |
| 1351 | proto.Array( |
| 1352 | proto.String("0"), |
| 1353 | proto.Array( |
| 1354 | proto.String("field1"), |
| 1355 | proto.String("1"), |
| 1356 | proto.String("field2"), |
| 1357 | proto.String("2"), |
| 1358 | ), |
| 1359 | ), |
| 1360 | ) |
| 1361 | |
| 1362 | // MATCH |
| 1363 | s.ZAdd("h", 3.0, "aap") |
| 1364 | s.ZAdd("h", 4.0, "noot") |
| 1365 | s.ZAdd("h", 5.0, "mies") |
| 1366 | mustDo(t, c, |
| 1367 | "ZSCAN", "h", "0", "MATCH", "mi*", |
| 1368 | proto.Array( |
| 1369 | proto.String("0"), |
| 1370 | proto.Array( |
nothing calls this directly
no test coverage detected