From 96571ac19cc564e7f056f5451af461fe2d299fd4 Mon Sep 17 00:00:00 2001 From: Christopher Herrera Date: Fri, 26 Jun 2015 13:36:33 -0400 Subject: [PATCH] unit tests added --- LICENSE | 0 README.md | 0 imdb.go | 0 imdb_test.go | 33 ++++++++++++++++++++++++++++ test-imdb/main_test.go | 49 ------------------------------------------ 5 files changed, 33 insertions(+), 49 deletions(-) mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 imdb.go create mode 100755 imdb_test.go delete mode 100644 test-imdb/main_test.go diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/imdb.go b/imdb.go old mode 100644 new mode 100755 diff --git a/imdb_test.go b/imdb_test.go new file mode 100755 index 0000000..233c05f --- /dev/null +++ b/imdb_test.go @@ -0,0 +1,33 @@ +package imdb + +import "testing" + +func TestImdbSearchMovies(t *testing.T) { + resp, err := SearchMovies("Fight Club", "1999") + if err != nil { + t.Error("Failed Search Movies") + } + if resp.Search[0].Title != "Fight Club" { + t.Error("Wrong Movie") + } +} + +func TestImdbGetMovieByTitle(t *testing.T) { + resp, err := GetMovieByTitle("Fight Club", "1999") + if err != nil { + t.Error("Failed GetMovieByTitle") + } + if resp.Title != "Fight Club" { + t.Error("Wrong Movie") + } +} + +func TestImdbGetMovieByImdbID(t *testing.T) { + resp, err := GetMovieByImdbID("tt0137523") + if err != nil { + t.Error("Failed GetMovieByImdbID") + } + if resp.Title != "Fight Club" { + t.Error("Wrong Movie") + } +} diff --git a/test-imdb/main_test.go b/test-imdb/main_test.go deleted file mode 100644 index 3529821..0000000 --- a/test-imdb/main_test.go +++ /dev/null @@ -1,49 +0,0 @@ -/* -Copyright 2014 Kaissersoft Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - imdb "github.com/eefret/go-imdb" - "testing" -) - -func TestMovieSearch(t *testing.T) { - //Testing SearchMovies - res, err := imdb.SearchMovies("The fifth element", "") - if err != nil { - t.Error(err) - } - t.Log(res.Search[0].Title) -} - -func TestGetMovieByTitle(t *testing.T) { - //Testing GetMovieByTitle - res2, err := imdb.GetMovieByTitle("True Grit", "1969") - if err != nil { - t.Error(err) - } - t.Log(res2.Title) -} - -func TestGetMovieByImdbId(t *testing.T) { - //Testing GetMovieByImdbId - res3, err := imdb.GetMovieByImdbID("tt2015381") - if err != nil { - t.Error(err) - } - t.Log(res3.Title) -}