41 lines
828 B
Bash
41 lines
828 B
Bash
#! /bin/bash
|
|
|
|
test__recurse_ids() {
|
|
local two_levels='{
|
|
"Branches": {
|
|
"id": {
|
|
"Branches": {
|
|
"subid": {
|
|
"Branches": {}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}'
|
|
(notnotea _recurse_ids "" "$two_levels"; true) | grep -q '^id$' || return 101
|
|
(notnotea _recurse_ids "" "$two_levels"; true) | tail -n 1 | grep -q '^id\/subid$' || return 102
|
|
notnotea _recurse_ids "" "$two_levels" | wc -l | grep -q 2 || return 103
|
|
}
|
|
|
|
test_meta() {
|
|
local two_levels='{
|
|
"Branches": {
|
|
"id": {
|
|
"Leaf": {"Title": "top level"},
|
|
"Branches": {
|
|
"subid": {
|
|
"Leaf": {"Title": "sub level"},
|
|
"Branches": {}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}'
|
|
notnotea eval "$(cat <<EOF
|
|
_tree() { echo '$two_levels'; }
|
|
meta id | jq .Title | grep -q top.level || return 101
|
|
meta id/subid | jq .Title | grep -q sub.level || return 102
|
|
EOF
|
|
)"
|
|
}
|