test notea

master
Bel LaPointe 2022-02-01 09:32:58 -07:00
parent 6c3229eeb3
commit 3b0f1bc02e
2 changed files with 60 additions and 2 deletions

View File

@ -7,8 +7,7 @@ notea() (
ids() { ids() {
ncurl $NOTEA_ADDR/api/tree \ ncurl $NOTEA_ADDR/api/tree \
| jq -r '.items \ | jq -r '.items | to_entries[].value.id' \
| to_entries[].value.id' \
| grep -v '^root$' | grep -v '^root$'
} }

59
app/crawler/notea_test.sh Normal file
View File

@ -0,0 +1,59 @@
#! /bin/bash
main() {
for t in $(grep ^test_* ./notea_test.sh | sed 's/(.*//'); do
each
echo run $t >&2
if ! eval "$t"; then
echo failed $t >&2
fi
done
}
each() {
export CACHE=$(mktemp -d)
source ./notea.sh
source ./cache.sh
}
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
ids | grep -q def
EOF
)"
}
test_get() {
notea eval "$(cat <<EOF
ncurl() {
echo "$*" | grep -q \/api\/notes\/abc
echo 'asdf'
}
! cache get "notea cache abc" | grep -q asdf
get abc | wc -l | grep -q 1
get abc | grep -q asdf
cache get "notea cache abc" | grep -q asdf
EOF
)"
}
if [ "$0" == "$BASH_SOURCE" ]; then
main "$@"
fi