Skip to content

Commit

Permalink
Add video & error test for shorts links
Browse files Browse the repository at this point in the history
  • Loading branch information
pajlada committed Apr 9, 2022
1 parent f51e74c commit 9a1ef2f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/resolvers/youtube/video_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ func TestVideoResolver(t *testing.T) {
inputReq: nil,
expectedBytes: []byte(`{"status":200,"thumbnail":"https://example.com/thumbnail.png","tooltip":"%3Cdiv%20style=%22text-align:%20left%3B%22%3E%0A%3Cb%3EVideo%20Title%3C%2Fb%3E%0A%3Cbr%3E%3Cb%3EChannel:%3C%2Fb%3E%20Channel%20Title%0A%3Cbr%3E%3Cb%3EDuration:%3C%2Fb%3E%2000:00:00%0A%3Cbr%3E%3Cb%3EPublished:%3C%2Fb%3E%2012%20Oct%202019%0A%3Cbr%3E%3Cb%3EViews:%3C%2Fb%3E%2050%0A%3Cbr%3E%3Cb%3E%3Cspan%20style=%22color:%20red%3B%22%3EAGE%20RESTRICTED%3C%2Fspan%3E%3C%2Fb%3E%0A%3Cbr%3E%3Cspan%20style=%22color:%20%232ecc71%3B%22%3E10%20likes%3C%2Fspan%3E\u0026nbsp%3B%E2%80%A2\u0026nbsp%3B%3Cspan%20style=%22color:%20%23808892%3B%22%3E5%20comments%3C%2Fspan%3E%0A%3C%2Fdiv%3E%0A"}`),
},
{
label: "Video (Short)",
inputURL: utils.MustParseURL("https://youtube.com/shorts/foobar"),
inputVideoID: "foobar",
inputReq: nil,
expectedBytes: []byte(`{"status":200,"thumbnail":"https://example.com/thumbnail.png","tooltip":"%3Cdiv%20style=%22text-align:%20left%3B%22%3E%0A%3Cb%3EVideo%20Title%3C%2Fb%3E%0A%3Cbr%3E%3Cb%3EChannel:%3C%2Fb%3E%20Channel%20Title%0A%3Cbr%3E%3Cb%3EDuration:%3C%2Fb%3E%2000:00:00%0A%3Cbr%3E%3Cb%3EPublished:%3C%2Fb%3E%2012%20Oct%202019%0A%3Cbr%3E%3Cb%3EViews:%3C%2Fb%3E%2050%0A%3Cbr%3E%3Cb%3E%3Cspan%20style=%22color:%20red%3B%22%3EAGE%20RESTRICTED%3C%2Fspan%3E%3C%2Fb%3E%0A%3Cbr%3E%3Cspan%20style=%22color:%20%232ecc71%3B%22%3E10%20likes%3C%2Fspan%3E\u0026nbsp%3B%E2%80%A2\u0026nbsp%3B%3Cspan%20style=%22color:%20%23808892%3B%22%3E5%20comments%3C%2Fspan%3E%0A%3C%2Fdiv%3E%0A"}`),
},
{
label: "404",
inputURL: utils.MustParseURL("https://youtube.com/watch?v=404"),
Expand All @@ -174,6 +181,13 @@ func TestVideoResolver(t *testing.T) {
inputReq: nil,
expectedBytes: []byte(`{"status":500,"message":"YouTube API returned more than 2 videos"}`),
},
{
label: "Too many videos (Short)",
inputURL: utils.MustParseURL("https://youtube.com/shorts/toomany"),
inputVideoID: "toomany",
inputReq: nil,
expectedBytes: []byte(`{"status":500,"message":"YouTube API returned more than 2 videos"}`),
},
{
label: "Unavailable",
inputURL: utils.MustParseURL("https://youtube.com/watch?v=unavailable"),
Expand Down

0 comments on commit 9a1ef2f

Please sign in to comment.