Skip to content
This repository has been archived by the owner on Oct 6, 2024. It is now read-only.

Commit

Permalink
api/test: Added table tests to the api package.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyah Check committed Sep 17, 2017
1 parent 8d1e81f commit d069368
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 17 deletions.
47 changes: 47 additions & 0 deletions api/api_test.go
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)
}
}
}
7 changes: 0 additions & 7 deletions api/apidata_test.go

This file was deleted.

6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#!/usr/bin/env bash

p=`pwd`
for d in $(ls ./cmd); do
echo "building cmd/$d"
cd $p/cmd/$d
for d in $(ls ./); do
echo "building main/$d"
cd $p/cm$d
env GOOS=linux GOARCH=386 go build
done
cd $p
7 changes: 0 additions & 7 deletions ytd_test.go

This file was deleted.

0 comments on commit d069368

Please sign in to comment.