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

40 lines
856 B
Bash

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