#!/usr/bin/env bash set -eu rootPath=$(dirname $(dirname $(realpath "$0"))) rm -v "$rootPath"/tmp/intake.db* || true cp -v "$rootPath"/test/*.sh "$rootPath/tmp/" go build -o "$rootPath/tmp/intake" export INTAKE_DATA_DIR="$rootPath/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 "HTML title" --link "#" --body "HTML body" 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" # 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 -- ./hello.sh tmp/intake source env -s hello --set "INTAKE_FETCH=every 1m" # and batch tmp/intake source env -s hello --set "INTAKE_BATCH=00:00" # default password, comment out to test no password echo "hello" | tmp/intake passwd --stdin echo "hello" | tmp/intake passwd --stdin --verify