notea-de-me/app/crawler/notea_test.sh

53 lines
1.2 KiB
Bash

#! /bin/bash
test_ids() {
notea eval "$(cat <<EOF
ncurl() {
case "\$1" in
*/api/tree )
echo '{
"items": {
"root": {
"children": [
"abc"
]
},
"abc": {
"id": "def"
},
"def": {
"pid": "root"
}
}
}'
;;
*/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
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
)"
}