intake/test/test_items.sh

66 lines
3.2 KiB
Bash
Raw Normal View History

2025-01-28 05:04:21 +00:00
#!/usr/bin/env bash
set -eu
go build -o tmp/intake
2025-01-28 05:54:46 +00:00
rm tmp/intake.db* || true
export INTAKE_DATA_DIR="tmp"
2025-01-28 05:04:21 +00:00
tmp/intake migrate
2025-02-10 16:22:19 +00:00
# testing item display format
2025-01-28 05:04:21 +00:00
tmp/intake source add -s feedtest
tmp/intake item add -s feedtest --id "this-item-has-no-title"
2025-02-06 15:28:53 +00:00
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"
2025-02-07 22:37:36 +00:00
tmp/intake action add -s feedtest -a fetch -- jq -cn '{id: "0", title: "Returned by fetch"}'
2025-02-10 16:22:19 +00:00
# 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}'
2025-02-05 20:14:53 +00:00
2025-02-10 16:22:19 +00:00
tmp/intake channel add -c home -s feedtest
tmp/intake channel add -c home -s spook
# testing empty feeds
2025-02-05 20:14:53 +00:00
tmp/intake source add -s nothing
2025-02-07 22:37:36 +00:00
tmp/intake action add -s nothing -a fetch -- true
2025-02-05 20:14:53 +00:00
tmp/intake channel add -c none -s nothing
2025-02-06 14:33:39 +00:00
2025-02-10 16:22:19 +00:00
# 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
2025-02-07 16:17:51 +00:00
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"
2025-02-20 15:18:51 +00:00
# test auto update
tmp/intake source env -s nothing --set "INTAKE_FETCH=every 5m"
tmp/intake source add -s hello
tmp/intake action add -s hello -a fetch -- sh -c "cat /dev/random | tr -dc 'A-Za-z0-9' | head -c16 | jq -cR '{id: ., title: \"Hello\"}'"
tmp/intake source env -s hello --set "INTAKE_FETCH=every 1m"
2025-02-10 16:22:19 +00:00
# default password, comment out to test no password
2025-02-06 14:33:39 +00:00
echo "hello" | tmp/intake passwd --stdin
echo "hello" | tmp/intake passwd --stdin --verify