(t *testing.T)
| 478 | } |
| 479 | |
| 480 | func TestLtrim(t *testing.T) { |
| 481 | server.Clear() |
| 482 | c, err := proto.Dial(server.Addr()) |
| 483 | ok(t, err) |
| 484 | defer c.Close() |
| 485 | s := server.Direct() |
| 486 | s.Push("l", "aap", "noot", "mies", "vuur") |
| 487 | |
| 488 | { |
| 489 | mustOK(t, c, "LTRIM", "l", "0", "2") |
| 490 | l, err := s.List("l") |
| 491 | ok(t, err) |
| 492 | equals(t, []string{"aap", "noot", "mies"}, l) |
| 493 | } |
| 494 | |
| 495 | // Delete key on empty list |
| 496 | { |
| 497 | mustOK(t, c, "LTRIM", "l", "0", "-99") |
| 498 | equals(t, false, s.Exists("l")) |
| 499 | } |
| 500 | |
| 501 | // Not existing key |
| 502 | mustOK(t, c, "LTRIM", "nonexisting", "0", "1") |
| 503 | |
| 504 | // Wrong type of key |
| 505 | t.Run("errors", func(t *testing.T) { |
| 506 | s.Set("str", "string!") |
| 507 | mustDo(t, c, |
| 508 | "LTRIM", "str", "0", "1", |
| 509 | proto.Error(msgWrongType), |
| 510 | ) |
| 511 | |
| 512 | mustDo(t, c, |
| 513 | "LTRIM", "l", "1", "2", "toomany", |
| 514 | proto.Error(errWrongNumber("ltrim")), |
| 515 | ) |
| 516 | mustDo(t, c, |
| 517 | "LTRIM", "l", "1", "noint", |
| 518 | proto.Error("ERR value is not an integer or out of range"), |
| 519 | ) |
| 520 | mustDo(t, c, |
| 521 | "LTRIM", "l", "noint", "1", |
| 522 | proto.Error("ERR value is not an integer or out of range"), |
| 523 | ) |
| 524 | mustDo(t, c, |
| 525 | "LTRIM", "l", "1", |
| 526 | proto.Error(errWrongNumber("ltrim")), |
| 527 | ) |
| 528 | mustDo(t, c, |
| 529 | "LTRIM", "l", |
| 530 | proto.Error(errWrongNumber("ltrim")), |
| 531 | ) |
| 532 | mustDo(t, c, |
| 533 | "LTRIM", |
| 534 | proto.Error(errWrongNumber("ltrim")), |
| 535 | ) |
| 536 | }) |
| 537 | } |
nothing calls this directly
no test coverage detected