| 364 | |
| 365 | @pytest.mark.redismod |
| 366 | def test_arrtrim(client): |
| 367 | client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) |
| 368 | assert 3 == client.json().arrtrim("arr", Path.root_path(), 1, 3) |
| 369 | assert [1, 2, 3] == client.json().get("arr") |
| 370 | |
| 371 | # <0 test, should be 0 equivalent |
| 372 | client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) |
| 373 | assert 0 == client.json().arrtrim("arr", Path.root_path(), -1, 3) |
| 374 | |
| 375 | # testing stop > end |
| 376 | client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) |
| 377 | assert 2 == client.json().arrtrim("arr", Path.root_path(), 3, 99) |
| 378 | |
| 379 | # start > array size and stop |
| 380 | client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) |
| 381 | assert 0 == client.json().arrtrim("arr", Path.root_path(), 9, 1) |
| 382 | |
| 383 | # all larger |
| 384 | client.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) |
| 385 | assert 0 == client.json().arrtrim("arr", Path.root_path(), 9, 11) |
| 386 | |
| 387 | |
| 388 | @pytest.mark.redismod |