-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.fish
executable file
·72 lines (56 loc) · 1.43 KB
/
tests.fish
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /usr/bin/env fish
# redfish: Use Redis from the fish shell.
# Copyright (c) 2023-2024 D. Bohdan.
# License: MIT.
cd "$(path dirname "$(status filename)")"
source functions/redfish.fish
begin
set --local initial foo1\nfoo2 bar βαζ
set --local key redfish:tests:k1
redfish set-list $key $initial
set --local got
redfish get-list got $key
if not test "$initial" = "$got"
printf '|%s| != |%s|\n' "$initial" "$got"
return 101
end
redfish set-list $key uno
redfish get-list got $key
test (count $got) -eq 1
or return 102
redfish set-list $key
redfish get-list got $key
test (count $got) -eq 0
or return 103
set got "$(redfish get $key)"
test "$got" = ''
or return 104
redfish set $key "$foo"
set got "$(redfish get $key)"
test "$got" = "$foo"
or return 105
redfish exists $key
or return 106
redfish del $key
or return 107
redfish del $key
and return 108
redfish exists $key
and return 109
redfish incr $key
redfish incr $key
redfish incr $key 3
redfish incr $key -2
test (redfish get $key) -eq 3
or return 110
test (redfish keys $key) = $key
or return 111
redfish set $key:a x
redfish set $key:b y
test "$(redfish del --verbose $key:a $key:b)" -eq 2
or return 112
set got "$(redfish get --raw $key)"
test "$got" = ''
or return 113
return 0
end