-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathkeys.t
38 lines (28 loc) · 801 Bytes
/
keys.t
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
#!/usr/bin/env bash
source test/setup
use Test::More tests 6
use JSON
tree1=$(cat test/keys.json | JSON.load)
ok $? \
"JSON.load succeeded"
is "$(JSON.get '/files/file 2.txt/type' tree1)" \
'"text/plain"' \
"JSON.get works"
file_object=$(JSON.object '/files' tree1)
# XXX Can't get osx and linux to sort these the same. Workaround:
expect="$(sort <<< "file1.txt"$'\n'"file 2.txt")"
keys="$(JSON.keys '/' file_object)"
is "$keys" \
"$expect" \
"JSON.keys '/'" #'
keys="$(JSON.keys '/files' tree1)"
is "$keys" \
"$expect" \
"JSON.keys '/files'" #'
keys="$(JSON.keys '/' tree1)"
is "$keys" "description"$'\n'"files" \
"JSON.keys '/'" #'
keys="$(JSON.keys '/files/file 2.txt' tree1)"
is "$keys" \
"content"$'\n'"type" \
"JSON.keys '/files/file 2.txt'" #'