Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yyoshiki41 committed Nov 26, 2016
1 parent 87ab5b4 commit 70a7006
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
4 changes: 2 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestEmptyHTTPClient(t *testing.T) {
client, err := New("")
if err == nil {
t.Errorf(
"Should detect HTTPClient is nil.\nclient: %v", client)
"Should detect that HTTPClient is nil.\nclient: %v", client)
}
}

Expand Down Expand Up @@ -96,7 +96,7 @@ func TestNewRequestWithEmptyContext(t *testing.T) {
var ctx context.Context
_, err = client.newRequest(ctx, "GET", "", &Params{})
if err == nil {
t.Error("Should detect empty context.")
t.Error("Should detect an empty context.")
}
}

Expand Down
2 changes: 1 addition & 1 deletion m3u8_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import (
func TestGetChunklistFromM3U8(t *testing.T) {
_, err := GetChunklistFromM3U8("")
if err == nil {
t.Error("Should detect error.")
t.Error("Should detect an error.")
}
}
6 changes: 3 additions & 3 deletions program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ func TestGetProgramByStartTimeEmptyStationID(t *testing.T) {

_, err = c.GetProgramByStartTime(context.Background(), "", time.Now())
if err == nil {
t.Error("Should detect error.")
t.Error("Should detect an error.")
}
}

func TestGetWeeklyPrograms(t *testing.T) {
client, err := New("")
c, err := New("")
if err != nil {
t.Fatalf("Failed to construct client: %s", err)
}

programs, err := client.GetWeeklyPrograms(context.Background(), "LFR")
programs, err := c.GetWeeklyPrograms(context.Background(), "LFR")
if err != nil {
t.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ func TestGetStreamMultiURL(t *testing.T) {
func TestNotExistsStreamMultiURL(t *testing.T) {
_, err := GetStreamMultiURL("TEST_LFR")
if err == nil {
t.Error("Should detect error.")
t.Error("Should detect an error.")
}
}
18 changes: 17 additions & 1 deletion timeshift_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package radiko

import "testing"
import (
"context"
"testing"
"time"
)

func TestTimeshiftPlaylistM3U8(t *testing.T) {
if isOutsideJP() {
Expand All @@ -14,3 +18,15 @@ func TestTimeshiftPlaylistM3U8(t *testing.T) {

_ = client
}

func TestEmptyStationIDTimeshiftPlaylistM3U8(t *testing.T) {
client, err := New("")
if err != nil {
t.Fatalf("Failed to construct client: %s", err)
}

_, err := c.TimeshiftPlaylistM3U8(context.Background(), "", time.Now())
if err == nil {
t.Error("Should detect an error.")
}
}

0 comments on commit 70a7006

Please sign in to comment.