This repository has been archived by the owner on Oct 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api/test: Added table tests to the api package.
- Loading branch information
Nyah Check
committed
Sep 17, 2017
1 parent
8d1e81f
commit d069368
Showing
4 changed files
with
50 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2017 YTD Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// api_test: Tests API package. | ||
|
||
package api | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
var tables = []struct { | ||
url string // input | ||
id string // expected result | ||
}{ | ||
{"https://www.youtube.com/watch?v=HpNluHOAJFA&list=RDHpNluHOAJFA", "HpNluHOAJFA"}, | ||
{"https://www.youtube.com/watch?v=jOWsu8ePrbE&list=RDHpNluHOAJFA&index=8", "jOWsu8ePrbE"}, | ||
{"", ""}, | ||
{"https://www.facebook.com/mark/videos?v=RDHpNluHOAJFA", ""}, | ||
{"https://www.youtube.com/watch?v=lWEbEtr_Vng", "lWEbEtr_Vng"}, | ||
{"https://www.wsj.com/articles/trump-administration-wont-withdraw-from-paris-climate-deal-1505593922", ""}, | ||
{"https://vimeo.com/101522071", ""}, | ||
} | ||
|
||
func TestApi(t *testing.T) { | ||
|
||
path := "~/Downloads/" | ||
for i, table := range tables { | ||
var rawVideo *RawVideoData | ||
ID, _ := GetVideoId(table.url) | ||
if ID != table.id { | ||
t.Errorf("GetVideoId(%d): expected %q, actual %q", i, table.id, ID) | ||
} | ||
|
||
video, err := APIGetVideoStream(ID, rawVideo) | ||
if err != nil { | ||
t.Errorf("APIGetVideoStream(%d): expected %v, actual %v", i, nil, err) | ||
} | ||
|
||
file := path + rawVideo.Title + rawVideo.Author | ||
err = APIConvertVideo(file, 123, ID, video) | ||
if err != nil { | ||
t.Errorf("APIConvertVideo(%d): expected %v, actual %v", i, nil, err) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.