test notea
parent
6c3229eeb3
commit
3b0f1bc02e
|
|
@ -7,8 +7,7 @@ notea() (
|
|||
|
||||
ids() {
|
||||
ncurl $NOTEA_ADDR/api/tree \
|
||||
| jq -r '.items \
|
||||
| to_entries[].value.id' \
|
||||
| jq -r '.items | to_entries[].value.id' \
|
||||
| grep -v '^root$'
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in New Issue