intake/test/test_items.sh

65 lines
3.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -eu
go build -o tmp/intake
rm tmp/intake.db* || true
export INTAKE_DATA_DIR="tmp"
tmp/intake migrate
# testing item display format
tmp/intake source add -s feedtest
tmp/intake item add -s feedtest --id "this-item-has-no-title"
tmp/intake item add -s feedtest --id a --title "This item has only a title"
tmp/intake item add -s feedtest --id b --title "Title and body" --body "This is the item body"
tmp/intake item add -s feedtest --id c --title "Title and link" --link "#"
tmp/intake item add -s feedtest --id d --title "Title, link, body" --link "#" --body "This is the body"
tmp/intake item add -s feedtest --id e --title "<b>HTML title</b>" --link "#" --body "<i>HTML body</i>"
tmp/intake item add -s feedtest --id f --title "Title and author" --author "Authorname"
tmp/intake item add -s feedtest --id g --title "Title, author, time" --author "Authorname" --time 1700000000
tmp/intake item add -s feedtest --id h --title "Title, time" --time 1737780324
tmp/intake item add -s feedtest --id i --title "Title, author, body" --author "Authorname" --body "Hello body!"
tmp/intake item add -s feedtest --id j --title "Title, author, time, body" --author "Authorname" --time 1700000000 --body "Hello body!"
tmp/intake item add -s feedtest --id k --title "Title, time, body" --time 1737780324 --body "Hello, body!"
tmp/intake item add -s feedtest --id l --title "TTL 30s" --ttl 30
tmp/intake item add -s feedtest --id m --title "TTL 10d" --ttl 864000
tmp/intake item add -s feedtest --id n --title "TTD 30s" --ttd 30
tmp/intake item add -s feedtest --id o --title "TTS 30s" --tts 30
tmp/intake item add -s feedtest --id p --title "TTS 10d" --tts 864000
tmp/intake item add -s feedtest --id q --title "TTS -10d" --tts "-864000"
tmp/intake action add -s feedtest -a fetch -- jq -cn '{id: "0", title: "Returned by fetch"}'
# testing actions that modify items
tmp/intake source add -s spook
tmp/intake action add -s spook -a spookier -- jq -c '.title = .title + "o"'
tmp/intake item add -s spook --id boo --title "Boo" --action '{"spookier": true}'
tmp/intake channel add -c home -s feedtest
tmp/intake channel add -c home -s spook
# testing empty feeds
tmp/intake source add -s nothing
tmp/intake action add -s nothing -a fetch -- true
tmp/intake channel add -c none -s nothing
# testing error items
tmp/intake source add -s gonnafail
tmp/intake action add -s gonnafail -a fetch -- sh -c 'echo Three... 1>&2; echo Two... 1>&2; echo One... 1>&2; echo BOOM!'
# testing feed paging
tmp/intake source add -s page
tmp/intake item add -s page --id 1 --title "Item 1" --body "This is the body of item 1"
for i in $(seq 2 211); do
tmp/intake item add -s page --id $i --title "Item $i" --body "This is the body of item $i" 2>/dev/null
done
tmp/intake item add -s page --id 212 --title "Item 212" --body "This is the body of item 212"
# default password, comment out to test no password
echo "hello" | tmp/intake passwd --stdin
echo "hello" | tmp/intake passwd --stdin --verify
# crontab integration
tmp/intake source env -s page --set "INTAKE_CRON=0 0 * * *"
tmp/intake source env -s spook --set "INTAKE_CRON=0 0 * * *"
tmp/intake source env -s feedtest --set "INTAKE_CRON=0 0 * * *"