-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroulette_test.go
76 lines (71 loc) · 2.35 KB
/
roulette_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package goroulette
import (
"log"
"strings"
"testing"
)
func TestMoviesByTitle(t *testing.T) {
movies, err := GetMoviesByTitle("Bad Boys")
if err != nil {
t.Errorf("Got unexpected error for requested title 'Bad Boys': %v", err)
return
}
if (Movie{}) == movies {
t.Errorf("Unexpected: could not get any movie with title 'Bad Boys'.")
}
if movies.GetTitle() != "Bad Boys" {
t.Errorf("Unexpected title for movie 'Bad Boys': expected '%s', got '%s' instead.", "Bad Boys", movies.GetTitle())
}
log.Printf("Fetched: %v", movies)
}
func TestMoviesByTitleAndYear(t *testing.T) {
movies, err := GetMoviesByTitleAndYear("Bad Boys", "1995")
if err != nil {
t.Errorf("Got unexpected error for requested title 'Bad Boys': %v", err)
return
}
if (Movie{}) == movies {
t.Errorf("Unexpected: could not get any movie with title 'Bad Boys'.")
}
if movies.GetTitle() != "Bad Boys" {
t.Errorf("Unexpected title for movie 'Bad Boys': expected '%s', got '%s' instead.", "Bad Boys", movies.GetTitle())
}
if movies.GetReleaseYear() != "1995" {
t.Errorf("Unexpected release year for movie 'Bad Boys': expected '%s', got '%s' instead.", "1995", movies.GetReleaseYear())
}
log.Printf("Fetched: %v", movies)
}
func TestMoviesByDirector(t *testing.T) {
movies, err := GetMoviesByDirector("Quentin Tarantino")
if err != nil {
t.Errorf("Got unexpected error for requested director 'Quentin Tarantino': %v", err)
return
}
if len(movies) < 1 {
t.Errorf("Unexpected: could not get any movie with director 'Quentin Tarantino'.")
}
if (movies)[0].GetDirector() != "Quentin Tarantino" {
t.Errorf("Unexpected director for director 'Quentin Tarantino': expected '%s', got '%s' instead.", "Quentin Tarantino", (movies)[0].GetDirector())
}
log.Printf("Fetched: %v", (movies)[0])
}
func TestMoviesByActor(t *testing.T) {
movies, err := GetMoviesByActor("Martin Lawrence")
if err != nil {
t.Errorf("Got unexpected error for requested actor 'Martin Lawrence': %v", err)
return
}
if len(movies) < 1 {
t.Errorf("Unexpected: could not get any movie with actor 'Martin Lawrence'.")
}
actors := strings.Split((movies)[0].GetShowCast(), ",")
for i := 0; i < len(actors); i++ {
if actors[i] == "Martin Lawrence" {
log.Printf("actor: %v", actors[i])
break
}
t.Errorf("Unexpected show cast for actor 'Martin Lawrence'.")
break
}
log.Printf("Fetched: %v", (movies)[0])
}