67 lines
1.5 KiB
Bash
67 lines
1.5 KiB
Bash
#! /bin/bash
|
|
|
|
test_ids() {
|
|
notea eval "$(cat <<EOF
|
|
ncurl() {
|
|
case "\$1" in
|
|
*/api/tree )
|
|
echo '{
|
|
"items": {
|
|
"root": {
|
|
"children": [
|
|
"abc",
|
|
"xyz"
|
|
]
|
|
},
|
|
"abc": {
|
|
"id": "def"
|
|
},
|
|
"def": {
|
|
"pid": "root"
|
|
},
|
|
"xyz": {
|
|
"pid": "root",
|
|
"deleted": 1,
|
|
"children": [
|
|
"wvu"
|
|
]
|
|
},
|
|
"wvu": {
|
|
"pid": "xyz",
|
|
"deleted": 0
|
|
}
|
|
}
|
|
}'
|
|
;;
|
|
*/api/notes/def/meta )
|
|
echo '{
|
|
"deleted": 0
|
|
}'
|
|
;;
|
|
* )
|
|
echo UNKNOWN NCURL "\$*" >&2
|
|
;;
|
|
esac
|
|
}
|
|
ids | wc -l | grep -q 1 || return 101
|
|
ids | grep -q def || return 102
|
|
! ids | grep -q wvu || return 103
|
|
! ids | grep -q xyz || return 104
|
|
EOF
|
|
)"
|
|
}
|
|
|
|
test_get() {
|
|
notea eval "$(cat <<EOF
|
|
ncurl() {
|
|
echo "$*" | grep -q \/api\/notes\/abc
|
|
echo 'asdf'
|
|
}
|
|
! cache get "notea cache abc" | grep -q asdf || return 101
|
|
get abc | wc -l | grep -q 1 || return 102
|
|
get abc | grep -q asdf || return 103
|
|
cache get "notea cache abc" | grep -q asdf || return 104
|
|
EOF
|
|
)"
|
|
}
|