2021-08-02 14:46:06 -07:00
#!/bin/bash
set -e
set -x
2021-08-03 17:34:44 -07:00
PS4 = '+(${BASH_SOURCE}:${LINENO}): '
2021-08-02 14:46:06 -07:00
test -e data && rm -r data
go run ./twitter create_profile data
# Fetch a user
go run ./twitter fetch_user data Denlesks
test $( sqlite3 data/twitter.db "select handle from users" ) = "Denlesks"
test $( sqlite3 data/twitter.db "select count(*) from users" ) = "1"
go run ./twitter fetch_user data Denlesks
test $( sqlite3 data/twitter.db "select count(*) from users" ) = "1"
# Fetch a tweet with images
go run ./twitter fetch_tweet_only data https://twitter.com/Denlesks/status/1261483383483293700
test $( sqlite3 data/twitter.db "select count(*) from tweets" ) = "1"
2021-08-02 14:55:59 -07:00
test " $( sqlite3 data/twitter.db "select text from tweets" ) " = "These are public health officials who are making decisions about your lifestyle because they know more about health, fitness and well-being than you do"
2021-08-05 14:10:46 -07:00
# Try to double-download it
2021-08-02 14:46:06 -07:00
go run ./twitter fetch_tweet_only data https://twitter.com/Denlesks/status/1261483383483293700
test $( sqlite3 data/twitter.db "select count(*) from tweets" ) = "1"
2021-08-05 14:10:46 -07:00
# Fetch a tweet with a video
go run ./twitter fetch_user data DiamondChariots
test $( sqlite3 data/twitter.db "select handle from users" | wc -l) = "2"
go run ./twitter fetch_tweet_only data https://twitter.com/DiamondChariots/status/1418971605674467340
test $( sqlite3 data/twitter.db "select count(*) from tweets" ) = "2"
# Try to double-download it
go run ./twitter fetch_tweet_only data https://twitter.com/DiamondChariots/status/1418971605674467340
test $( sqlite3 data/twitter.db "select count(*) from tweets" ) = "2"
test $( sqlite3 data/twitter.db "select count(*) from videos" ) = "1"
echo -e "\033[32mAll tests passed. Finished successfully.\033[0m"