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

40 lines
772 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
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
)"
}