Пример #1
0
func Test404GetMovie(t *testing.T) {
	tmdb := New()
	_, err := tmdb.GetMovie("foo") // Do not exist
	if err != nil && err.Error() != "404 Not Found" {
		t.Errorf("It should fail with '404 Not Found', but got: %v", err)
	}
}
Пример #2
0
func TestGetMovie(t *testing.T) {
	tmdb := New()
	_, err := tmdb.GetMovie("603") // The Matrix
	if err != nil {
		t.Errorf("It should not fail, but got an error: %s", err)
	}
}
Пример #3
0
func TestBadAPIKeyGetMovie(t *testing.T) {
	tmdb := New()
	tmdb.APIKey = "foo"
	_, err := tmdb.GetMovie("603") // The Matrix
	if err != nil && err.Error() != "401 Unauthorized" {
		t.Errorf("It should fail with '401 Unauthorized', but got: %v", err)
	}
}
Пример #4
0
func TestBadURLGetMovie(t *testing.T) {
	tmdb := New()
	tmdb.BaseURL, _ = url.Parse("http://foo.bar/")
	_, err := tmdb.GetMovie("603") // The Matrix
	if err == nil {
		t.Errorf("It should fail because the BaseURL %s, does not exist.", tmdb.BaseURL)
	}
}