| 376 | |
| 377 | @pytest.mark.redismod |
| 378 | async def test_arrtrim(decoded_r: redis.Redis): |
| 379 | await decoded_r.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) |
| 380 | assert 3 == await decoded_r.json().arrtrim("arr", Path.root_path(), 1, 3) |
| 381 | assert [1, 2, 3] == await decoded_r.json().get("arr") |
| 382 | |
| 383 | # <0 test, should be 0 equivalent |
| 384 | await decoded_r.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) |
| 385 | assert 0 == await decoded_r.json().arrtrim("arr", Path.root_path(), -1, 3) |
| 386 | |
| 387 | # testing stop > end |
| 388 | await decoded_r.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) |
| 389 | assert 2 == await decoded_r.json().arrtrim("arr", Path.root_path(), 3, 99) |
| 390 | |
| 391 | # start > array size and stop |
| 392 | await decoded_r.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) |
| 393 | assert 0 == await decoded_r.json().arrtrim("arr", Path.root_path(), 9, 1) |
| 394 | |
| 395 | # all larger |
| 396 | await decoded_r.json().set("arr", Path.root_path(), [0, 1, 2, 3, 4]) |
| 397 | assert 0 == await decoded_r.json().arrtrim("arr", Path.root_path(), 9, 11) |
| 398 | |
| 399 | |
| 400 | @pytest.mark.redismod |