Add some tests for multiple videos / videos+images

This commit is contained in:
Alessio 2022-10-15 15:50:25 -04:00
parent 4b5b098b9e
commit 5877063748
2 changed files with 38 additions and 0 deletions

View File

@ -98,6 +98,39 @@ tw download_tweet_content https://twitter.com/Cernovich/status/14444295170202746
test $(find videos -mindepth 2 | wc -l) = "$((initial_videos_count + 1))"
# Fetch a tweet with 2 gifs
initial_videos_count=$(find videos -mindepth 2 | wc -l)
test $(sqlite3 twitter.db "select count(*) from videos where tweet_id = 1580185800968327168 and is_gif = 1") = "0"
tw fetch_tweet https://twitter.com/emo_garfield420/status/1580185800968327168
test $(find videos -mindepth 2 | wc -l) = "$((initial_videos_count + 2))"
test $(sqlite3 twitter.db "select count(*) from videos where tweet_id = 1580185800968327168 and is_gif = 1") = "2"
# Fetch a tweet with 2 videos
test $(sqlite3 twitter.db "select count(*) from videos where tweet_id = 1579701786252042240 and is_gif = 0") = "0"
tw fetch_user FairwayWill
tw fetch_tweet_only https://twitter.com/FairwayWill/status/1579701786252042240
test $(sqlite3 twitter.db "select count(*) from videos where tweet_id = 1579701786252042240 and is_gif = 0") = "2"
initial_videos_count=$(find videos -mindepth 2 | wc -l)
tw download_tweet_content https://twitter.com/FairwayWill/status/1579701786252042240
test $(find videos -mindepth 2 | wc -l) = "$((initial_videos_count + 2))"
# Fetch a tweet with a video and an image
test $(sqlite3 twitter.db "select count(*) from videos where tweet_id = 1579292281898766336") = "0"
test $(sqlite3 twitter.db "select count(*) from images where tweet_id = 1579292281898766336") = "0"
tw fetch_user mexicanwilddog
tw fetch_tweet_only https://twitter.com/mexicanwilddog/status/1579292281898766336
test $(sqlite3 twitter.db "select count(*) from videos where tweet_id = 1579292281898766336") = "1"
test $(sqlite3 twitter.db "select count(*) from images where tweet_id = 1579292281898766336") = "1"
initial_videos_count=$(find videos -mindepth 2 | wc -l)
initial_images_count=$(find images -mindepth 2 | wc -l)
tw download_tweet_content https://twitter.com/mexicanwilddog/status/1579292281898766336
test $(find videos -mindepth 2 | wc -l) = "$((initial_videos_count + 1))"
test $(find images -mindepth 2 | wc -l) = "$((initial_images_count + 1))"
# Fetch a tweet with a poll
tw fetch_tweet 1465534109573390348
test $(sqlite3 twitter.db "select count(*) from polls where tweet_id = 1465534109573390348") = "1"

View File

@ -101,9 +101,14 @@ func TestParseTweetWith2Videos(t *testing.T) {
v1 := tweet.Videos[0]
assert.Equal("https://video.twimg.com/ext_tw_video/1579701730148847617/pu/vid/576x576/ghA0fyf58v-2naWR.mp4?tag=12", v1.RemoteURL)
assert.False(v1.IsGif)
assert.Equal("gh/ghA0fyf58v-2naWR.mp4", v1.LocalFilename)
assert.Equal("xU/xUlghaCXbPOVN7vI.jpg", v1.ThumbnailLocalPath)
v2 := tweet.Videos[1]
assert.Equal("https://video.twimg.com/ext_tw_video/1579701730157252608/pu/vid/480x480/VQ69Ut84XT2BgIzX.mp4?tag=12", v2.RemoteURL)
assert.False(v2.IsGif)
assert.Equal("VQ/VQ69Ut84XT2BgIzX.mp4", v2.LocalFilename)
assert.Equal("dY/dYN55HDytKvM1Bi8.jpg", v2.ThumbnailLocalPath)
}
func TestParseTweetWithImageAndVideo(t *testing.T) {