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

Commit

Permalink
Update main package and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyah Check committed Jan 3, 2020
1 parent b82baa7 commit 1d4a0de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 55 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ func main() {
//Get Video Id
if ids == "" {
url := os.Args[1]
startProcessing([]string{url})
beginDownload([]string{url})
} else {
startProcessing(strings.Split(ids, ","))
beginDownload(strings.Split(ids, ","))
}
}

func startProcessing(urls []string) {
func beginDownload(urls []string) {
ch := downloadStreams(defaultMaxDownloads, format, path, bitrate, urls)
for err := range ch {
//Extract Video data and decode
Expand Down
56 changes: 4 additions & 52 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,13 @@ package main

import (
"fmt"
"reflect"
"testing"
)

//Version combines the OS and architecture
type Version struct {
OS string
Arch string
func TestDownloader(t *testing.T) {
urls := []string{"https://www.youtube.com/watch?v=HpNluHOAJFA&list=RDHpNluHOAJFA"}

Default bool // indicates whether Version is a build target
}

func (vs *Version) String() string {
return fmt.Sprintf("%s/%s", vs.OS, vs.Arch)
}

var (
Versions_1_0 = []Version{
{"darwin", "amd64", true},
{"linux", "amd64", true},
{"windows", "amd64", true},
}

Versions_1_1 = append(Versions_1_0)
Versions_1_2 = append(Versions_1_1)
Versions_1_3 = append(Versions_1_2)
)

func SupportedVersions(v string) []Version {
return []Version{
{"darwin", "amd64", true},
{"linux", "amd64", true},
}
}

func TestGoVersions(t *testing.T) {
var versions []Version

versions = SupportedVersions("go1.10")
if !reflect.DeepEqual(versions, Versions_1_0) {
t.Fatalf("bad: %#v", versions)
}

versions = SupportedVersions("go1.11")
if !reflect.DeepEqual(versions, Versions_1_1) {
t.Fatalf("bad: %#v", versions)
}

versions = SupportedVersions("go1.12")
if !reflect.DeepEqual(versions, Versions_1_2) {
t.Fatalf("bad: %#v", versions)
}

versions = SupportedVersions("go1.13")
if !reflect.DeepEqual(versions, Versions_1_3) {
t.Fatalf("bad: %#v", versions)
if err := beginDownload(urls); err != nil {
fmt.Fprintln("Error occured testing downloader", err)
}
}

0 comments on commit 1d4a0de

Please sign in to comment.