Skip to content

Commit

Permalink
all tests has been fixed (#54)
Browse files Browse the repository at this point in the history
* all tests has been fixed

* id fix
  • Loading branch information
cyruzin authored Feb 6, 2024
1 parent 1ffc8ed commit bde7a62
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 47 deletions.
6 changes: 3 additions & 3 deletions companies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package tmdb

const (
lucasFilmID = 1
disneyID = 2
randomID = 3
)

func (suite *TMBDTestSuite) TestGetCompanyDetails() {
Expand Down Expand Up @@ -30,13 +30,13 @@ func (suite *TMBDTestSuite) TestGetCompanyAlternativeNamesFail() {
}

func (suite *TMBDTestSuite) TestGetCompanyImages() {
company, err := suite.client.GetCompanyImages(disneyID)
company, err := suite.client.GetCompanyImages(randomID)
suite.Nil(err)
suite.NotNil(company.ID)
}

func (suite *TMBDTestSuite) TestGetCompanyImagesFail() {
suite.client.apiKey = ""
_, err := suite.client.GetCompanyImages(disneyID)
_, err := suite.client.GetCompanyImages(randomID)
suite.NotNil(err)
}
30 changes: 14 additions & 16 deletions movies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (suite *TMBDTestSuite) TestGetMovieDetails() {

func (suite *TMBDTestSuite) TestGetMovieDetailsFail() {
_, err := suite.client.GetMovieDetails(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieDetailsWithOptions() {
Expand All @@ -41,7 +41,7 @@ func (suite *TMBDTestSuite) TestGetMovieAlternativeTitles() {

func (suite *TMBDTestSuite) TestGetMovieAlternativeTitlesFail() {
_, err := suite.client.GetMovieAlternativeTitles(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieAlternativeTitlesWithOptions() {
Expand All @@ -62,11 +62,9 @@ func (suite *TMBDTestSuite) TestGetMovieChanges() {
}
}

// The API isn't handling zero values for this end-point.
// TODO: Fix this test later.
func (suite *TMBDTestSuite) TestGetMovieChangesFail() {
_, err := suite.client.GetMovieChanges(0, nil)
suite.Nil(err)
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieChangesWithOptions() {
Expand All @@ -91,7 +89,7 @@ func (suite *TMBDTestSuite) TestGetMovieCredits() {

func (suite *TMBDTestSuite) TestGetMovieCreditsFail() {
_, err := suite.client.GetMovieCredits(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieExternalIDs() {
Expand All @@ -102,7 +100,7 @@ func (suite *TMBDTestSuite) TestGetMovieExternalIDs() {

func (suite *TMBDTestSuite) TestGetMovieExternalIDsFail() {
_, err := suite.client.GetMovieExternalIDs(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieImages() {
Expand All @@ -113,7 +111,7 @@ func (suite *TMBDTestSuite) TestGetMovieImages() {

func (suite *TMBDTestSuite) TestGetMovieImagesFail() {
_, err := suite.client.GetMovieImages(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieImagesWithOptions() {
Expand All @@ -132,7 +130,7 @@ func (suite *TMBDTestSuite) TestGetMovieKeywords() {

func (suite *TMBDTestSuite) TestGetMovieKeywordsFail() {
_, err := suite.client.GetMovieKeywords(0)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieReleaseDates() {
Expand All @@ -143,7 +141,7 @@ func (suite *TMBDTestSuite) TestGetMovieReleaseDates() {

func (suite *TMBDTestSuite) TestGetMovieReleaseDatesFail() {
_, err := suite.client.GetMovieReleaseDates(0)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieAccountStatesFail() {
Expand All @@ -167,7 +165,7 @@ func (suite *TMBDTestSuite) TestGetMovieVideos() {

func (suite *TMBDTestSuite) TestGetMovieVideosFail() {
_, err := suite.client.GetMovieVideos(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieVideosWithOptions() {
Expand All @@ -186,7 +184,7 @@ func (suite *TMBDTestSuite) TestGetMovieTranslations() {

func (suite *TMBDTestSuite) TestGetMovieTranslationsFail() {
_, err := suite.client.GetMovieTranslations(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieTranslationsWithOptions() {
Expand All @@ -205,7 +203,7 @@ func (suite *TMBDTestSuite) TestGetMovieRecommendations() {

func (suite *TMBDTestSuite) TestGetMovieRecommendationsFail() {
_, err := suite.client.GetMovieRecommendations(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieRecommendationsWithOptions() {
Expand All @@ -224,7 +222,7 @@ func (suite *TMBDTestSuite) TestGetMovieWatchProviders() {

func (suite *TMBDTestSuite) TestGetMovieWatchProvidersFail() {
_, err := suite.client.GetMovieWatchProviders(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieSimilar() {
Expand All @@ -235,7 +233,7 @@ func (suite *TMBDTestSuite) TestGetMovieSimilar() {

func (suite *TMBDTestSuite) TestGetMovieSimilarFail() {
_, err := suite.client.GetMovieSimilar(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieSimilarWithOptions() {
Expand All @@ -254,7 +252,7 @@ func (suite *TMBDTestSuite) TestGetMovieReviews() {

func (suite *TMBDTestSuite) TestGetMovieReviewsFail() {
_, err := suite.client.GetMovieReviews(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetMovieReviewsWithOptions() {
Expand Down
14 changes: 7 additions & 7 deletions tv_episodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func (suite *TMBDTestSuite) TestGetTVEpisodeDetails() {

func (suite *TMBDTestSuite) TestGetTVEpisodeDetailsFail() {
_, err := suite.client.GetTVEpisodeDetails(0, 1, 1, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVEpisodeDetailsWithOptions() {
Expand All @@ -31,7 +31,7 @@ func (suite *TMBDTestSuite) TestGetTVEpisodeChangesFail() {
options["end_date"] = "2019-01-25"
options["page"] = "1"
_, err := suite.client.GetTVEpisodeChanges(0, options)
suite.Nil(err)
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVEpisodeChangesWithOptions() {
Expand All @@ -52,7 +52,7 @@ func (suite *TMBDTestSuite) TestGetTVEpisodeCredits() {

func (suite *TMBDTestSuite) TestGetTVEpisodeCreditsFail() {
_, err := suite.client.GetTVEpisodeCredits(0, 1, 1)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVEpisodeExternalIDs() {
Expand All @@ -63,7 +63,7 @@ func (suite *TMBDTestSuite) TestGetTVEpisodeExternalIDs() {

func (suite *TMBDTestSuite) TestGetTVEpisodeExternalIDsFail() {
_, err := suite.client.GetTVEpisodeExternalIDs(0, 1, 1)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVEpisodeImages() {
Expand All @@ -74,7 +74,7 @@ func (suite *TMBDTestSuite) TestGetTVEpisodeImages() {

func (suite *TMBDTestSuite) TestGetTVEpisodeImagesFail() {
_, err := suite.client.GetTVEpisodeImages(0, 1, 1)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVEpisodeTranslations() {
Expand All @@ -85,7 +85,7 @@ func (suite *TMBDTestSuite) TestGetTVEpisodeTranslations() {

func (suite *TMBDTestSuite) TestGetTVEpisodeTranslationsFail() {
_, err := suite.client.GetTVEpisodeTranslations(0, 1, 1)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVEpisodeVideos() {
Expand All @@ -96,7 +96,7 @@ func (suite *TMBDTestSuite) TestGetTVEpisodeVideos() {

func (suite *TMBDTestSuite) TestGetTVEpisodeVideosFail() {
_, err := suite.client.GetTVEpisodeVideos(0, 1, 2, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVEpisodeVideosWithOptions() {
Expand Down
4 changes: 2 additions & 2 deletions tv_seasons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func (suite *TMBDTestSuite) TestGetTVSeasonDetails() {

func (suite *TMBDTestSuite) TestGetTVSeasonDetailsFail() {
_, err := suite.client.GetTVSeasonDetails(0, 1, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVSeasonDetailsWithOptions() {
Expand Down Expand Up @@ -117,5 +117,5 @@ func (suite *TMBDTestSuite) TestGetTVSeasonTranslations() {

func (suite *TMBDTestSuite) TestGetTVSeasonTranslationsFail() {
_, err := suite.client.GetTVSeasonTranslations(0, 1)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}
36 changes: 17 additions & 19 deletions tv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (suite *TMBDTestSuite) TestGetTVDetails() {

func (suite *TMBDTestSuite) TestGetTVDetailsFail() {
_, err := suite.client.GetTVDetails(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVDetailsWithOptions() {
Expand Down Expand Up @@ -51,7 +51,7 @@ func (suite *TMBDTestSuite) TestGetTVAggregateCredits() {

func (suite *TMBDTestSuite) TestGetTVAggregateFail() {
_, err := suite.client.GetTVAggregateCredits(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVAlternativeTitles() {
Expand All @@ -66,7 +66,7 @@ func (suite *TMBDTestSuite) TestGetTVAlternativeTitles() {

func (suite *TMBDTestSuite) TestGetTVAlternativeTitlesFail() {
_, err := suite.client.GetTVAlternativeTitles(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVAlternativeTitlesWithOptions() {
Expand All @@ -83,11 +83,9 @@ func (suite *TMBDTestSuite) TestGetTVChanges() {
suite.NotNil(changes)
}

// The API isn't handling zero values for this end-point.
// TODO: Fix this test later.
func (suite *TMBDTestSuite) TestGetTVChangesFail() {
_, err := suite.client.GetTVChanges(0, nil)
suite.Nil(err)
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVChangesWithOptions() {
Expand All @@ -112,7 +110,7 @@ func (suite *TMBDTestSuite) TestGetTVContentRatings() {

func (suite *TMBDTestSuite) TestGetTVContentRatingsFail() {
_, err := suite.client.GetTVContentRatings(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVContentRatingsWithOptions() {
Expand All @@ -131,7 +129,7 @@ func (suite *TMBDTestSuite) TestGetTVCredits() {

func (suite *TMBDTestSuite) TestGetTVCreditsFail() {
_, err := suite.client.GetTVCredits(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVEpisodeGroups() {
Expand All @@ -142,7 +140,7 @@ func (suite *TMBDTestSuite) TestGetTVEpisodeGroups() {

func (suite *TMBDTestSuite) TestGetTVEpisodeGroupsFail() {
_, err := suite.client.GetTVEpisodeGroups(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVEpisodeGroupsWithOptions() {
Expand All @@ -161,7 +159,7 @@ func (suite *TMBDTestSuite) TestGetTVExternalIDs() {

func (suite *TMBDTestSuite) TestGetTVExternalIDsFail() {
_, err := suite.client.GetTVExternalIDs(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVImages() {
Expand All @@ -172,7 +170,7 @@ func (suite *TMBDTestSuite) TestGetTVImages() {

func (suite *TMBDTestSuite) TestGetTVImagesFail() {
_, err := suite.client.GetTVImages(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVImagesWithOptions() {
Expand All @@ -191,7 +189,7 @@ func (suite *TMBDTestSuite) TestGetTVKeywords() {

func (suite *TMBDTestSuite) TestGetTVKeywordsFail() {
_, err := suite.client.GetTVKeywords(0)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVRecommendations() {
Expand All @@ -202,7 +200,7 @@ func (suite *TMBDTestSuite) TestGetTVRecommendations() {

func (suite *TMBDTestSuite) TestGetTVRecommendationsFail() {
_, err := suite.client.GetTVRecommendations(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVRecommendationsWithOptions() {
Expand All @@ -221,7 +219,7 @@ func (suite *TMBDTestSuite) TestGetTVScreenedTheatrically() {

func (suite *TMBDTestSuite) TestGetTVScreenedTheatricallyFail() {
_, err := suite.client.GetTVScreenedTheatrically(0)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVReviews() {
Expand All @@ -232,7 +230,7 @@ func (suite *TMBDTestSuite) TestGetTVReviews() {

func (suite *TMBDTestSuite) TestGetTVReviewsFail() {
_, err := suite.client.GetTVReviews(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVReviewsWithOptions() {
Expand All @@ -251,7 +249,7 @@ func (suite *TMBDTestSuite) TestGetTVWatchProviders() {

func (suite *TMBDTestSuite) TestGetTVWatchProvidersFail() {
_, err := suite.client.GetTVWatchProviders(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVSimilar() {
Expand All @@ -262,7 +260,7 @@ func (suite *TMBDTestSuite) TestGetTVSimilar() {

func (suite *TMBDTestSuite) TestGetTVSimilarFail() {
_, err := suite.client.GetTVSimilar(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVSimilarWithOptions() {
Expand All @@ -281,7 +279,7 @@ func (suite *TMBDTestSuite) TestGetTVTranslations() {

func (suite *TMBDTestSuite) TestGetTVTranslationsFail() {
_, err := suite.client.GetTVTranslations(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVTranslationsWithOptions() {
Expand All @@ -300,7 +298,7 @@ func (suite *TMBDTestSuite) TestGetTVVideos() {

func (suite *TMBDTestSuite) TestGetTVVideosFail() {
_, err := suite.client.GetTVVideos(0, nil)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}

func (suite *TMBDTestSuite) TestGetTVVideosWithOptions() {
Expand Down

0 comments on commit bde7a62

Please sign in to comment.