Skip to content

Commit

Permalink
Add movie integration tests (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamayoung authored Jul 26, 2023
1 parent 73839c7 commit 1a77ab2
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Integration.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@
}
],
"defaultOptions" : {
"environmentVariableEntries" : [
{
"key" : "TMDB_API_KEY",
"value" : "cf458964ba75aa9d53a21578df3747ed"
}
],
"language" : "en",
"region" : "GB",
"testExecutionOrdering" : "random"
},
"testTargets" : [
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:",
"identifier" : "TMDbIntegrationTests",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ extension XCTestCase {
}

static var tmdbAPIKey: String {
guard let apiKey = ProcessInfo.processInfo.environment["TMDB_API_KEY"] else {
guard
let apiKey = ProcessInfo.processInfo.environment["TMDB_API_KEY"],
!apiKey.isEmpty
else {
preconditionFailure("TMDb configuration API key not set. Use TMDB_API_KEY environment variable.")
}

Expand Down
78 changes: 78 additions & 0 deletions Tests/TMDbIntegrationTests/MovieIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,82 @@ final class MovieIntegrationTests: XCTestCase {
XCTAssertEqual(movie.title, "Barbie")
}

func testCredits() async throws {
let movieID = 346698

let credits = try await movieService.credits(forMovie: movieID)

XCTAssertEqual(credits.id, movieID)
XCTAssertFalse(credits.cast.isEmpty)
XCTAssertFalse(credits.crew.isEmpty)
}

func testReviews() async throws {
let movieID = 346698

let reviewList = try await movieService.reviews(forMovie: movieID)

XCTAssertFalse(reviewList.results.isEmpty)
}

func testImages() async throws {
let movieID = 346698

let imageCollection = try await movieService.images(forMovie: movieID)

XCTAssertEqual(imageCollection.id, movieID)
XCTAssertFalse(imageCollection.posters.isEmpty)
XCTAssertFalse(imageCollection.logos.isEmpty)
XCTAssertFalse(imageCollection.backdrops.isEmpty)
}

func testVideos() async throws {
let movieID = 346698

let videoCollection = try await movieService.videos(forMovie: movieID)

XCTAssertEqual(videoCollection.id, movieID)
XCTAssertFalse(videoCollection.results.isEmpty)
}

func testRecommendations() async throws {
let movieID = 921636

let recommendationList = try await movieService.recommendations(forMovie: movieID)

XCTAssertFalse(recommendationList.results.isEmpty)
}

func testSimilar() async throws {
let movieID = 921636

let movieList = try await movieService.similar(toMovie: movieID)

XCTAssertFalse(movieList.results.isEmpty)
}

func testNowPlaying() async throws {
let movieList = try await movieService.nowPlaying()

XCTAssertFalse(movieList.results.isEmpty)
}

func testPopular() async throws {
let movieList = try await movieService.popular()

XCTAssertFalse(movieList.results.isEmpty)
}

func testTopRated() async throws {
let movieList = try await movieService.topRated()

XCTAssertFalse(movieList.results.isEmpty)
}

func testUpcoming() async throws {
let movieList = try await movieService.upcoming()

XCTAssertFalse(movieList.results.isEmpty)
}

}

0 comments on commit 1a77ab2

Please sign in to comment.