(t *testing.T)
| 493 | } |
| 494 | |
| 495 | func TestHscan(t *testing.T) { |
| 496 | server.Clear() |
| 497 | |
| 498 | c, err := proto.Dial(server.Addr()) |
| 499 | ok(t, err) |
| 500 | defer c.Close() |
| 501 | |
| 502 | // We cheat with hscan. It always returns everything. |
| 503 | directDo(t, c, "HSET", "h", "field1", "value1") |
| 504 | directDo(t, c, "HSET", "h", "field2", "value2") |
| 505 | |
| 506 | // No problem |
| 507 | mustDo(t, c, |
| 508 | "HSCAN", "h", "0", |
| 509 | proto.Array( |
| 510 | proto.String("0"), |
| 511 | proto.Array( |
| 512 | proto.String("field1"), |
| 513 | proto.String("value1"), |
| 514 | proto.String("field2"), |
| 515 | proto.String("value2"), |
| 516 | ), |
| 517 | ), |
| 518 | ) |
| 519 | |
| 520 | // Invalid cursor |
| 521 | mustDo(t, c, |
| 522 | "HSCAN", "h", "42", |
| 523 | proto.Array( |
| 524 | proto.String("0"), |
| 525 | proto.Array(), |
| 526 | ), |
| 527 | ) |
| 528 | |
| 529 | // COUNT (ignored) |
| 530 | mustDo(t, c, |
| 531 | "HSCAN", "h", "0", "COUNT", "200", |
| 532 | proto.Array( |
| 533 | proto.String("0"), |
| 534 | proto.Array( |
| 535 | proto.String("field1"), |
| 536 | proto.String("value1"), |
| 537 | proto.String("field2"), |
| 538 | proto.String("value2"), |
| 539 | ), |
| 540 | ), |
| 541 | ) |
| 542 | |
| 543 | // MATCH |
| 544 | directDo(t, c, "HSET", "h", "aap", "a") |
| 545 | directDo(t, c, "HSET", "h", "noot", "b") |
| 546 | directDo(t, c, "HSET", "h", "mies", "m") |
| 547 | mustDo(t, c, |
| 548 | "HSCAN", "h", "0", "MATCH", "mi*", |
| 549 | proto.Array( |
| 550 | proto.String("0"), |
| 551 | proto.Array( |
| 552 | proto.String("mies"), |
nothing calls this directly
no test coverage detected