From f86922ab270064eef6487300cb882a36801766d7 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Thu, 14 Nov 2024 21:27:09 +0000 Subject: [PATCH] REFACTOR: Remove random data in test mocks (#215) --- .../Movies/TMDbMovieServiceReviewsTests.swift | 4 +- .../Search/TMDbSearchServiceTests.swift | 24 ++++----- .../TMDbTVEpisodeServiceTests.swift | 28 +++++----- .../TVSeasons/TMDbTVSeasonServiceTests.swift | 28 +++++----- .../TMDbTVSeriesServiceListsTests.swift | 13 +++-- .../TMDbTVSeriesServiceMediaTests.swift | 4 +- .../TMDbTVSeriesServiceReviewsTests.swift | 4 +- .../Mocks/Models/CastMember+Mocks.swift | 18 +++---- .../Mocks/Models/Certification+Mocks.swift | 6 +-- .../Mocks/Models/Company+Mocks.swift | 12 ++--- .../Mocks/Models/Country+Mocks.swift | 4 +- .../Mocks/Models/CrewMember+Mocks.swift | 14 ++--- .../Mocks/Models/Department+Mocks.swift | 4 +- .../TMDbTests/Mocks/Models/Genre+Mocks.swift | 4 +- .../Mocks/Models/ImageCollection+Mocks.swift | 2 +- .../Mocks/Models/ImageMetadata+Mocks.swift | 12 ++--- .../Models/ImagesConfiguration+Mocks.swift | 4 +- .../Mocks/Models/Language+Mocks.swift | 4 +- .../Models/MediaPageableList+Mocks.swift | 6 +-- .../TMDbTests/Mocks/Models/Movie+Mocks.swift | 40 +++++++------- .../Mocks/Models/MovieListItem+Mocks.swift | 20 +++---- .../Models/MoviePageableList+Mocks.swift | 6 +-- .../TMDbTests/Mocks/Models/Person+Mocks.swift | 24 ++++----- .../Models/PersonCombinedCredits+Mocks.swift | 2 +- .../Models/PersonImageCollection+Mocks.swift | 2 +- .../Mocks/Models/PersonListItem+Mocks.swift | 10 ++-- .../Models/PersonMovieCredits+Mocks.swift | 2 +- .../Models/PersonPageableList+Mocks.swift | 6 +-- .../Models/PersonTVSeriesCredits+Mocks.swift | 2 +- .../Models/ProductionCompany+Mocks.swift | 10 ++-- .../Models/ProductionCountry+Mocks.swift | 4 +- .../TMDbTests/Mocks/Models/Review+Mocks.swift | 8 +-- .../Models/ReviewPageableList+Mocks.swift | 6 +-- .../Mocks/Models/ShowCredits+Mocks.swift | 2 +- .../ShowWatchProviderResult+Mocks.swift | 2 +- .../Mocks/Models/SpokenLanguage+Mocks.swift | 4 +- .../Mocks/Models/TVEpisode+Mocks.swift | 14 ++--- .../TVEpisodeImageCollection+Mocks.swift | 2 +- .../Mocks/Models/TVSeason+Mock.swift | 8 +-- .../TVSeasonImageCollection+Mocks.swift | 2 +- .../Mocks/Models/TVSeries+Mocks.swift | 6 +-- .../Mocks/Models/TVSeriesListItem+Mocks.swift | 14 ++--- .../Models/TVSeriesPageableList+Mocks.swift | 6 +-- .../Mocks/Models/VideoCollection+Mocks.swift | 2 +- .../Mocks/Models/VideoMetadata+Mocks.swift | 4 +- .../Mocks/Models/WatchProvider+Mocks.swift | 4 +- Tests/TMDbTests/Mocks/URL+Mocks.swift | 39 -------------- ...te+RandomDate.swift => Date+ISO8601.swift} | 13 +++-- Tests/TMDbTests/TestUtils/Int+RandomID.swift | 28 ---------- .../TestUtils/JSONEncoder+TMDb.swift | 54 ------------------- .../TMDbTests/TestUtils/String+RandomID.swift | 32 ----------- 51 files changed, 213 insertions(+), 360 deletions(-) delete mode 100644 Tests/TMDbTests/Mocks/URL+Mocks.swift rename Tests/TMDbTests/TestUtils/{Date+RandomDate.swift => Date+ISO8601.swift} (70%) delete mode 100644 Tests/TMDbTests/TestUtils/Int+RandomID.swift delete mode 100644 Tests/TMDbTests/TestUtils/JSONEncoder+TMDb.swift delete mode 100644 Tests/TMDbTests/TestUtils/String+RandomID.swift diff --git a/Tests/TMDbTests/Domain/Services/Movies/TMDbMovieServiceReviewsTests.swift b/Tests/TMDbTests/Domain/Services/Movies/TMDbMovieServiceReviewsTests.swift index b8f0704f..dda025ef 100644 --- a/Tests/TMDbTests/Domain/Services/Movies/TMDbMovieServiceReviewsTests.swift +++ b/Tests/TMDbTests/Domain/Services/Movies/TMDbMovieServiceReviewsTests.swift @@ -35,7 +35,7 @@ struct TMDbMovieServiceReviewsTests { @Test("reviews returns reviews") func reviewsReturnsReviews() async throws { - let movieID = Int.randomID + let movieID = 1 let expectedResult = ReviewPageableList.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = MovieReviewsRequest(id: movieID, page: nil, language: nil) @@ -48,7 +48,7 @@ struct TMDbMovieServiceReviewsTests { @Test("reviews with page and language returns reviews") func reviewsWithPageAndLanguageReturnsReviews() async throws { - let movieID = Int.randomID + let movieID = 1 let expectedResult = ReviewPageableList.mock() let page = expectedResult.page let language = "en" diff --git a/Tests/TMDbTests/Domain/Services/Search/TMDbSearchServiceTests.swift b/Tests/TMDbTests/Domain/Services/Search/TMDbSearchServiceTests.swift index 80cd0dd7..8da2fc5d 100644 --- a/Tests/TMDbTests/Domain/Services/Search/TMDbSearchServiceTests.swift +++ b/Tests/TMDbTests/Domain/Services/Search/TMDbSearchServiceTests.swift @@ -35,7 +35,7 @@ struct TMDbSearchServiceTests { @Test("searchAll returns media") func searchAllReturnsMedia() async throws { - let query = String.random + let query = "media search" let expectedResult = MediaPageableList.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = MultiSearchRequest( @@ -49,7 +49,7 @@ struct TMDbSearchServiceTests { @Test("searchAll with filter, page and language returns media") func searchAllWithFilterAndPageAndLanguageReturnsMedia() async throws { - let query = String.random + let query = "media search" let includeAdult = true let page = 2 let language = "en" @@ -72,7 +72,7 @@ struct TMDbSearchServiceTests { @Test("searchAll when errors throws error") func searchAllWhenErrorsThrowsError() async throws { - let query = String.random + let query = "media search" apiClient.addResponse(.failure(.unknown)) await #expect(throws: TMDbError.unknown) { @@ -82,7 +82,7 @@ struct TMDbSearchServiceTests { @Test("searchMovies returns movies") func searchMoviesReturnsMovies() async throws { - let query = String.random + let query = "search movies" let expectedResult = MoviePageableList.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = MovieSearchRequest( @@ -101,7 +101,7 @@ struct TMDbSearchServiceTests { @Test("searchMovies with filter, page and language returns movies") func searchMoviesWithFilterAndPageAndLanguageReturnsMovies() async throws { - let query = String.random + let query = "search movies" let primaryReleaseYear = 2024 let country = "GB" let includeAdult = true @@ -132,7 +132,7 @@ struct TMDbSearchServiceTests { @Test("searchMovies when errors throws error") func searchMoviesWhenErrorsThrowsError() async throws { - let query = String.random + let query = "search movies" apiClient.addResponse(.failure(.unknown)) await #expect(throws: TMDbError.unknown) { @@ -142,7 +142,7 @@ struct TMDbSearchServiceTests { @Test("searchTVSeries returns TV series") func searchTVSeriesReturnsTVSeries() async throws { - let query = String.random + let query = "search tv series" let expectedResult = TVSeriesPageableList.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = TVSeriesSearchRequest( @@ -162,7 +162,7 @@ struct TMDbSearchServiceTests { @Test("searchTVSeries with filter, page and language returns TV series") func searchTVSeriesWithFilterAndPageAndLanguageReturnsTVSeries() async throws { - let query = String.random + let query = "search tv series" let firstAirDateYear = 2023 let year = 2024 let includeAdult = true @@ -190,7 +190,7 @@ struct TMDbSearchServiceTests { @Test("searchTVSeries when errors throws error") func searchTVSeriesWhenErrorsThrowsError() async throws { - let query = String.random + let query = "search tv series" apiClient.addResponse(.failure(.unknown)) await #expect(throws: TMDbError.unknown) { @@ -200,7 +200,7 @@ struct TMDbSearchServiceTests { @Test("searchPeople returns people") func searchPeopleReturnsPeople() async throws { - let query = String.random + let query = "search people" let expectedResult = PersonPageableList.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = PersonSearchRequest( @@ -214,7 +214,7 @@ struct TMDbSearchServiceTests { @Test("searchPeople with filter, page and language returns people") func searchPeopleWithFilterAndPageAndLanguageReturnsPeople() async throws { - let query = String.random + let query = "search people" let includeAdult = true let page = 2 let language = "en" @@ -237,7 +237,7 @@ struct TMDbSearchServiceTests { @Test("searchPeople when errors throws error") func searchPeopleWhenErrorsThrowsError() async throws { - let query = String.random + let query = "search people" apiClient.addResponse(.failure(.unknown)) await #expect(throws: TMDbError.unknown) { diff --git a/Tests/TMDbTests/Domain/Services/TVEpisodes/TMDbTVEpisodeServiceTests.swift b/Tests/TMDbTests/Domain/Services/TVEpisodes/TMDbTVEpisodeServiceTests.swift index 6352adda..8b754db0 100644 --- a/Tests/TMDbTests/Domain/Services/TVEpisodes/TMDbTVEpisodeServiceTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVEpisodes/TMDbTVEpisodeServiceTests.swift @@ -35,7 +35,7 @@ struct TMDbTVEpisodeServiceTests { @Test("details returns TV episode") func detailsReturnsTVEpisode() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let expectedResult = TVEpisode.mock() let seasonNumber = expectedResult.seasonNumber let episodeNumber = expectedResult.episodeNumber @@ -59,7 +59,7 @@ struct TMDbTVEpisodeServiceTests { @Test("details with language returns TV episode") func detailsWithLanguageReturnsTVEpisode() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let expectedResult = TVEpisode.mock() let seasonNumber = expectedResult.seasonNumber let episodeNumber = expectedResult.episodeNumber @@ -101,9 +101,9 @@ struct TMDbTVEpisodeServiceTests { @Test("images returns images") func imagesReturnsImages() async throws { - let episodeNumber = Int.randomID - let seasonNumber = Int.randomID - let tvSeriesID = Int.randomID + let episodeNumber = 111 + let seasonNumber = 11 + let tvSeriesID = 1 let expectedResult = TVEpisodeImageCollection.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = TVEpisodeImagesRequest( @@ -125,9 +125,9 @@ struct TMDbTVEpisodeServiceTests { @Test("images with filter returns images") func imagesWithFilterReturnsImages() async throws { - let episodeNumber = Int.randomID - let seasonNumber = Int.randomID - let tvSeriesID = Int.randomID + let episodeNumber = 111 + let seasonNumber = 11 + let tvSeriesID = 1 let languages = ["en-GB", "fr"] let expectedResult = TVEpisodeImageCollection.mock() apiClient.addResponse(.success(expectedResult)) @@ -168,9 +168,9 @@ struct TMDbTVEpisodeServiceTests { @Test("video returns videos") func videosReturnsVideos() async throws { - let episodeNumber = Int.randomID - let seasonNumber = Int.randomID - let tvSeriesID = Int.randomID + let episodeNumber = 111 + let seasonNumber = 11 + let tvSeriesID = 1 let expectedResult = VideoCollection.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = TVEpisodeVideosRequest( @@ -192,9 +192,9 @@ struct TMDbTVEpisodeServiceTests { @Test("video with filter returns videos") func videosWithFilterReturnsVideos() async throws { - let episodeNumber = Int.randomID - let seasonNumber = Int.randomID - let tvSeriesID = Int.randomID + let episodeNumber = 111 + let seasonNumber = 11 + let tvSeriesID = 1 let languages = ["en", "fr"] let expectedResult = VideoCollection.mock() apiClient.addResponse(.success(expectedResult)) diff --git a/Tests/TMDbTests/Domain/Services/TVSeasons/TMDbTVSeasonServiceTests.swift b/Tests/TMDbTests/Domain/Services/TVSeasons/TMDbTVSeasonServiceTests.swift index c5bc8d41..93729d93 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeasons/TMDbTVSeasonServiceTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeasons/TMDbTVSeasonServiceTests.swift @@ -35,7 +35,7 @@ struct TMDbTVSeasonServiceTests { @Test("details returns TV season") func detailsReturnsTVSeason() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let expectedResult = TVSeason.mock() let seasonNumber = expectedResult.seasonNumber apiClient.addResponse(.success(expectedResult)) @@ -53,7 +53,7 @@ struct TMDbTVSeasonServiceTests { @Test("details with language returns TV season") func detailsWithLanguageReturnsTVSeason() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let expectedResult = TVSeason.mock() let seasonNumber = expectedResult.seasonNumber let language = "en" @@ -84,9 +84,9 @@ struct TMDbTVSeasonServiceTests { @Test("aggregateCredits returns TV season credits") func aggregateCreditsReturnsTVSeasonCredits() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let expectedResult = TVSeasonAggregateCredits(id: 1, cast: [], crew: []) - let seasonNumber = Int.randomID + let seasonNumber = 11 apiClient.addResponse(.success(expectedResult)) let expectedRequest = TVSeasonAggregateCreditsRequest( seasonNumber: seasonNumber, @@ -103,9 +103,9 @@ struct TMDbTVSeasonServiceTests { @Test("aggregateCredits with language returns TV season credits") func aggregateCreditsWithLanguageReturnsTVSeasonCredits() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let expectedResult = TVSeasonAggregateCredits(id: 1, cast: [], crew: []) - let seasonNumber = Int.randomID + let seasonNumber = 11 let language = "en" apiClient.addResponse(.success(expectedResult)) let expectedRequest = TVSeasonAggregateCreditsRequest( @@ -137,8 +137,8 @@ struct TMDbTVSeasonServiceTests { @Test("imagess returns images") func imagesReturnsImages() async throws { - let seasonNumber = Int.randomID - let tvSeriesID = Int.randomID + let seasonNumber = 11 + let tvSeriesID = 1 let expectedResult = TVSeasonImageCollection.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = TVSeasonImagesRequest( @@ -155,8 +155,8 @@ struct TMDbTVSeasonServiceTests { @Test("images with filter returns images") func imagesWithFilterReturnsImages() async throws { - let seasonNumber = Int.randomID - let tvSeriesID = Int.randomID + let seasonNumber = 11 + let tvSeriesID = 1 let languages = ["en-GB", "fr"] let expectedResult = TVSeasonImageCollection.mock() apiClient.addResponse(.success(expectedResult)) @@ -187,8 +187,8 @@ struct TMDbTVSeasonServiceTests { @Test("videos returns videos") func videosReturnsVideos() async throws { - let seasonNumber = Int.randomID - let tvSeriesID = Int.randomID + let seasonNumber = 11 + let tvSeriesID = 1 let expectedResult = VideoCollection.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = TVSeasonVideosRequest( @@ -205,8 +205,8 @@ struct TMDbTVSeasonServiceTests { @Test("videos with filter returns videos") func videosWithFilterReturnsVideos() async throws { - let seasonNumber = Int.randomID - let tvSeriesID = Int.randomID + let seasonNumber = 11 + let tvSeriesID = 1 let languages = ["en", "fr"] let expectedResult = VideoCollection.mock() apiClient.addResponse(.success(expectedResult)) diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceListsTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceListsTests.swift index 3c3189b8..3e8595c3 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceListsTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceListsTests.swift @@ -35,11 +35,14 @@ struct TMDbTVSeriesServiceListsTests { @Test("recommenendations returns TV series") func recommendationsReturnsTVSeries() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let expectedResult = TVSeriesPageableList.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = TVSeriesRecommendationsRequest( - id: tvSeriesID, page: nil, language: nil) + id: tvSeriesID, + page: nil, + language: nil + ) let result = try await service.recommendations(forTVSeries: tvSeriesID) @@ -49,7 +52,7 @@ struct TMDbTVSeriesServiceListsTests { @Test("recommendations with page and language returns TV series") func recommendationsWithPageAndLanguageReturnsTVSeries() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let page = 2 let language = "en" let expectedResult = TVSeriesPageableList.mock() @@ -76,7 +79,7 @@ struct TMDbTVSeriesServiceListsTests { @Test("similar returns TV series") func similarReturnsTVSeries() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let expectedResult = TVSeriesPageableList.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = SimilarTVSeriesRequest(id: tvSeriesID, page: nil, language: nil) @@ -89,7 +92,7 @@ struct TMDbTVSeriesServiceListsTests { @Test("similar with page and language returns TV series") func similarWithPageAndLanguageReturnsTVSeries() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let page = 2 let language = "en" let expectedResult = TVSeriesPageableList.mock() diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceMediaTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceMediaTests.swift index 8816ede9..b14eabef 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceMediaTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceMediaTests.swift @@ -35,7 +35,7 @@ struct TMDbTVSeriesServiceMediaTests { @Test("images returns images") func imagesReturnsImages() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let expectedResult = ImageCollection.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = TVSeriesImagesRequest(id: tvSeriesID, languages: nil) @@ -48,7 +48,7 @@ struct TMDbTVSeriesServiceMediaTests { @Test("images with filter returns images") func imagesWithFilterReturnsImages() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let languages = ["en-GB", "fr"] let expectedResult = ImageCollection.mock() apiClient.addResponse(.success(expectedResult)) diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceReviewsTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceReviewsTests.swift index 251e1fcf..9c52d79e 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceReviewsTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceReviewsTests.swift @@ -35,7 +35,7 @@ struct TMDbTVSeriesServiceReviewsTests { @Test("reviews returns reviews") func reviewsReturnsReviews() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let expectedResult = ReviewPageableList.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = TVSeriesReviewsRequest(id: tvSeriesID, page: nil, language: nil) @@ -48,7 +48,7 @@ struct TMDbTVSeriesServiceReviewsTests { @Test("reviews with language returns reviews") func reviewsWithLanguageReturnsReviews() async throws { - let tvSeriesID = Int.randomID + let tvSeriesID = 1 let language = "en" let expectedResult = ReviewPageableList.mock() apiClient.addResponse(.success(expectedResult)) diff --git a/Tests/TMDbTests/Mocks/Models/CastMember+Mocks.swift b/Tests/TMDbTests/Mocks/Models/CastMember+Mocks.swift index c8480524..bf4df3ab 100644 --- a/Tests/TMDbTests/Mocks/Models/CastMember+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/CastMember+Mocks.swift @@ -23,21 +23,21 @@ import TMDb extension CastMember { static func mock( - id: Int = .randomID, - castID: Int? = .randomID, - creditID: String = .randomID, - name: String? = .random, - character _: String? = .random, + id: Int = 1, + castID: Int? = 2, + creditID: String = "3", + name: String = "Actor Name", + character: String = "Character Name", gender: Gender? = .male, - profilePath: URL? = .randomImagePath, - order: Int = Int.random(in: 1...10) + profilePath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + order: Int = 1 ) -> Self { .init( id: id, castID: castID, creditID: creditID, - name: name ?? "Cast \(id)", - character: name ?? "Character \(id)", + name: name, + character: character, gender: gender, profilePath: profilePath, order: order diff --git a/Tests/TMDbTests/Mocks/Models/Certification+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Certification+Mocks.swift index 458c01e9..3a712ac1 100644 --- a/Tests/TMDbTests/Mocks/Models/Certification+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Certification+Mocks.swift @@ -23,13 +23,13 @@ import TMDb extension Certification { static func mock( - code: String = .random, - meaning: String? = nil, + code: String = "U", + meaning: String = "All ages admitted, there is nothing unsuitable for children.", order: Int = 1 ) -> Self { .init( code: code, - meaning: meaning ?? "Meaning \(code)", + meaning: meaning, order: order ) } diff --git a/Tests/TMDbTests/Mocks/Models/Company+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Company+Mocks.swift index ae38f4e5..95db1be9 100644 --- a/Tests/TMDbTests/Mocks/Models/Company+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Company+Mocks.swift @@ -23,12 +23,12 @@ import TMDb extension Company { static func mock( - id: Int = .randomID, - name: String = .random, - description: String = .random, - headquarters: String = .random, - homepageURL: URL = .randomWebSite, - logoPath: URL = .randomImagePath, + id: Int = 1, + name: String = "Lucasfilm Ltd.", + description: String = "Some description", + headquarters: String = "San Francisco, California", + homepageURL: URL = URL(string: "https://www.lucasfilm.com")!, + logoPath: URL = URL(string: "/o86DbpburjxrqAzEDhXZcyE8pDb.png")!, originCountry: String = "US", parentCompany: Company.Parent? = nil ) -> Self { diff --git a/Tests/TMDbTests/Mocks/Models/Country+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Country+Mocks.swift index 210d1a73..f366c65e 100644 --- a/Tests/TMDbTests/Mocks/Models/Country+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Country+Mocks.swift @@ -24,8 +24,8 @@ extension Country { static func mock( countryCode: String = "US", - name: String = .random, - englishName: String = .random + name: String = "United States", + englishName: String = "United States of America" ) -> Self { .init( countryCode: countryCode, diff --git a/Tests/TMDbTests/Mocks/Models/CrewMember+Mocks.swift b/Tests/TMDbTests/Mocks/Models/CrewMember+Mocks.swift index 3c1fd8a1..8aa69949 100644 --- a/Tests/TMDbTests/Mocks/Models/CrewMember+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/CrewMember+Mocks.swift @@ -23,18 +23,18 @@ import TMDb extension CrewMember { static func mock( - id: Int = .randomID, - creditID: String = .randomID, - name: String? = nil, - job: String = "Job \(String.random)", - department: String = "Department \(String.random))", + id: Int = 1, + creditID: String = "2", + name: String = "Crew Name", + job: String = "Job Name", + department: String = "Department Name", gender: Gender? = Gender.male, - profilePath: URL? = .randomImagePath + profilePath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")! ) -> Self { .init( id: id, creditID: creditID, - name: name ?? "Crew Member \(id)", + name: name, job: job, department: department, gender: gender, diff --git a/Tests/TMDbTests/Mocks/Models/Department+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Department+Mocks.swift index 389b2f3e..26fd63b3 100644 --- a/Tests/TMDbTests/Mocks/Models/Department+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Department+Mocks.swift @@ -23,8 +23,8 @@ import TMDb extension Department { static func mock( - name: String = .random, - jobs: [String] = [.random, .random] + name: String = "Costume & Make-Up", + jobs: [String] = ["Set Costumer", "Co-Costume Designer"] ) -> Self { .init( name: name, diff --git a/Tests/TMDbTests/Mocks/Models/Genre+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Genre+Mocks.swift index e065f361..b95ea4fb 100644 --- a/Tests/TMDbTests/Mocks/Models/Genre+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Genre+Mocks.swift @@ -24,8 +24,8 @@ import Foundation extension Genre { static func mock( - id: Int = .randomID, - name: String = .random + id: Int = 1, + name: String = "Action" ) -> Self { .init( id: id, diff --git a/Tests/TMDbTests/Mocks/Models/ImageCollection+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ImageCollection+Mocks.swift index 44ae5546..616df5bf 100644 --- a/Tests/TMDbTests/Mocks/Models/ImageCollection+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ImageCollection+Mocks.swift @@ -23,7 +23,7 @@ import TMDb extension ImageCollection { static func mock( - id: Int = .randomID, + id: Int = 1, posters: [ImageMetadata] = .mocks, logos: [ImageMetadata] = .mocks, backdrops: [ImageMetadata] = .mocks diff --git a/Tests/TMDbTests/Mocks/Models/ImageMetadata+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ImageMetadata+Mocks.swift index 12984ec0..bf235b87 100644 --- a/Tests/TMDbTests/Mocks/Models/ImageMetadata+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ImageMetadata+Mocks.swift @@ -23,12 +23,12 @@ import TMDb extension ImageMetadata { static func mock( - filePath: URL = .randomImagePath, - width: Int = Int.random(in: 10...100), - height: Int = Int.random(in: 10...100), - aspectRatio: Float = Float.random(in: 1.0...5.0), - voteAverage: Float = Float.random(in: 0.0...10.0), - voteCount: Int = Int.random(in: 0...1000), + filePath: URL = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + width: Int = 100, + height: Int = 100, + aspectRatio: Float = 1, + voteAverage: Float = 5, + voteCount: Int = 100, languageCode: String = "en" ) -> Self { .init( diff --git a/Tests/TMDbTests/Mocks/Models/ImagesConfiguration+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ImagesConfiguration+Mocks.swift index 29c2e4e1..ac5e21f4 100644 --- a/Tests/TMDbTests/Mocks/Models/ImagesConfiguration+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ImagesConfiguration+Mocks.swift @@ -23,8 +23,8 @@ import TMDb extension ImagesConfiguration { static func mock( - baseURL: URL = .randomBaseURL(secure: false), - secureBaseURL: URL = .randomBaseURL(), + baseURL: URL = URL(string: "http://api.domain.com/v1/")!, + secureBaseURL: URL = URL(string: "https://api.domain.com/v1/")!, backdropSizes: [String] = ["w300"], logoSizes: [String] = ["w45"], posterSizes: [String] = ["w92"], diff --git a/Tests/TMDbTests/Mocks/Models/Language+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Language+Mocks.swift index 71123b05..6415880d 100644 --- a/Tests/TMDbTests/Mocks/Models/Language+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Language+Mocks.swift @@ -24,8 +24,8 @@ extension Language { static func mock( code: String = "en", - name: String = .random, - englishName: String = .random + name: String = "English", + englishName: String = "English" ) -> Self { .init( code: code, diff --git a/Tests/TMDbTests/Mocks/Models/MediaPageableList+Mocks.swift b/Tests/TMDbTests/Mocks/Models/MediaPageableList+Mocks.swift index b01796cc..6151ca82 100644 --- a/Tests/TMDbTests/Mocks/Models/MediaPageableList+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/MediaPageableList+Mocks.swift @@ -23,10 +23,10 @@ import TMDb extension MediaPageableList { static func mock( - page: Int = Int.random(in: 1...5), + page: Int = 1, results: [Media] = .mocks, - totalResults: Int? = Int.random(in: 1...100), - totalPages: Int? = Int.random(in: 1...5) + totalResults: Int? = 10, + totalPages: Int? = 2 ) -> Self { .init( page: page, diff --git a/Tests/TMDbTests/Mocks/Models/Movie+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Movie+Mocks.swift index 6e2d0c1a..1a6b7771 100644 --- a/Tests/TMDbTests/Mocks/Models/Movie+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Movie+Mocks.swift @@ -24,36 +24,36 @@ import Foundation extension Movie { static func mock( - id: Int = Int.randomID, - title: String? = nil, - tagline: String? = .random, + id: Int = 1, + title: String = "Movie name", + tagline: String? = "Movie Tag Line", originalTitle: String? = nil, originalLanguage: String? = "en", - overview: String? = .random, - runtime: Int? = Int.random(in: 60...240), - genres: [Genre]? = .mocks, - releaseDate: Date? = .random, - posterPath: URL? = .randomImagePath, - backdropPath: URL? = .randomImagePath, - budget: Double? = Double.random(in: 1_000_000...65_000_000), - revenue: Double? = Double.random(in: 1_000_000...65_000_000), - homepageURL: URL? = .randomWebSite, - imdbID: String? = .randomID, + overview: String? = "Movie Overview", + runtime: Int? = 120, + genres: [Genre]? = [.action, .drama], + releaseDate: Date? = Date(iso8601: "2013-11-15T10:20:00Z"), + posterPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + backdropPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + budget: Double? = 1_000_000, + revenue: Double? = 5_000_000, + homepageURL: URL? = URL(string: "https://www.movie.com")!, + imdbID: String? = "12345", status: Status? = .released, productionCompanies: [ProductionCompany]? = .mocks, productionCountries: [ProductionCountry]? = .mocks, spokenLanguages: [SpokenLanguage]? = .mocks, - popularity: Double? = Double.random(in: 1...10), - voteAverage: Double? = Double.random(in: 1...10), - voteCount: Int? = Int.random(in: 1...1000), - hasVideo: Bool? = .random(), - isAdultOnly: Bool? = .random() + popularity: Double? = 5, + voteAverage: Double? = 6, + voteCount: Int? = 120, + hasVideo: Bool? = false, + isAdultOnly: Bool? = false ) -> Self { .init( id: id, - title: title ?? "Movie \(id)", + title: title, tagline: tagline, - originalTitle: originalTitle ?? title ?? "Movie \(id)", + originalTitle: originalTitle, originalLanguage: originalLanguage, overview: overview, runtime: runtime, diff --git a/Tests/TMDbTests/Mocks/Models/MovieListItem+Mocks.swift b/Tests/TMDbTests/Mocks/Models/MovieListItem+Mocks.swift index b3e89aa1..93b427b3 100644 --- a/Tests/TMDbTests/Mocks/Models/MovieListItem+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/MovieListItem+Mocks.swift @@ -24,20 +24,20 @@ import Foundation extension MovieListItem { static func mock( - id: Int = Int.randomID, + id: Int = 1, title: String = "Movie", originalTitle: String = "Movie a", originalLanguage: String = "en", - overview: String = .random, + overview: String = "Movie Overview", genreIDs: [Genre.ID] = [Genre].mocks.map(\.id), - releaseDate: Date? = .random, - posterPath: URL? = .randomImagePath, - backdropPath: URL? = .randomImagePath, - popularity: Double? = Double.random(in: 1...10), - voteAverage: Double? = Double.random(in: 1...10), - voteCount: Int? = Int.random(in: 1...1000), - hasVideo: Bool? = .random(), - isAdultOnly: Bool? = .random() + releaseDate: Date? = Date(iso8601: "2013-11-15T10:20:00Z"), + posterPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + backdropPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + popularity: Double? = 5.6, + voteAverage: Double? = 7.3, + voteCount: Int? = 321, + hasVideo: Bool? = false, + isAdultOnly: Bool? = false ) -> Self { .init( id: id, diff --git a/Tests/TMDbTests/Mocks/Models/MoviePageableList+Mocks.swift b/Tests/TMDbTests/Mocks/Models/MoviePageableList+Mocks.swift index d356a3b7..290a7307 100644 --- a/Tests/TMDbTests/Mocks/Models/MoviePageableList+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/MoviePageableList+Mocks.swift @@ -23,10 +23,10 @@ import TMDb extension MoviePageableList { static func mock( - page: Int = .random(in: 1...5), + page: Int = 1, results: [MovieListItem] = .mocks, - totalResults: Int = .random(in: 1...100), - totalPages: Int = .random(in: 1...5) + totalResults: Int = 10, + totalPages: Int = 2 ) -> Self { .init( page: page, diff --git a/Tests/TMDbTests/Mocks/Models/Person+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Person+Mocks.swift index 5c0534a1..14558f79 100644 --- a/Tests/TMDbTests/Mocks/Models/Person+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Person+Mocks.swift @@ -23,24 +23,24 @@ import TMDb extension Person { static func mock( - id: Int = .randomID, - name: String = .random, - alsoKnownAs: [String]? = nil, - knownForDepartment: String? = .random, - biography: String? = .random, - birthday: Date? = .random, + id: Int = 1, + name: String = "Person Name", + alsoKnownAs: [String] = ["Person Name"], + knownForDepartment: String? = nil, + biography: String? = nil, + birthday: Date? = Date(iso8601: "2013-11-15T10:20:00Z"), deathday: Date? = nil, gender: Gender = .unknown, - placeOfBirth: String? = .random, - profilePath: URL? = .randomImagePath, - popularity: Double? = Double.random(in: 1...10), - imdbID: String? = .random, - homepageURL: URL? = .randomWebSite + placeOfBirth: String? = nil, + profilePath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + popularity: Double? = 6.8, + imdbID: String? = nil, + homepageURL: URL? = URL(string: "https://www.person.com")! ) -> Self { .init( id: id, name: name, - alsoKnownAs: alsoKnownAs ?? [name], + alsoKnownAs: alsoKnownAs, knownForDepartment: knownForDepartment, biography: biography, birthday: birthday, diff --git a/Tests/TMDbTests/Mocks/Models/PersonCombinedCredits+Mocks.swift b/Tests/TMDbTests/Mocks/Models/PersonCombinedCredits+Mocks.swift index 5e56c47d..31821389 100644 --- a/Tests/TMDbTests/Mocks/Models/PersonCombinedCredits+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/PersonCombinedCredits+Mocks.swift @@ -23,7 +23,7 @@ import TMDb extension PersonCombinedCredits { static func mock( - id: Int = .randomID, + id: Int = 1, cast: [Show] = [ .movie(.jurassicWorldDominion), .tvSeries(.bigBrother), diff --git a/Tests/TMDbTests/Mocks/Models/PersonImageCollection+Mocks.swift b/Tests/TMDbTests/Mocks/Models/PersonImageCollection+Mocks.swift index 2164faed..ce05fb88 100644 --- a/Tests/TMDbTests/Mocks/Models/PersonImageCollection+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/PersonImageCollection+Mocks.swift @@ -23,7 +23,7 @@ import TMDb extension PersonImageCollection { static func mock( - id: Int = .randomID, + id: Int = 1, profiles: [ImageMetadata] = [.mock(), .mock()] ) -> Self { .init( diff --git a/Tests/TMDbTests/Mocks/Models/PersonListItem+Mocks.swift b/Tests/TMDbTests/Mocks/Models/PersonListItem+Mocks.swift index 52b72469..eb362378 100644 --- a/Tests/TMDbTests/Mocks/Models/PersonListItem+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/PersonListItem+Mocks.swift @@ -23,13 +23,13 @@ import TMDb extension PersonListItem { static func mock( - id: Int = .randomID, - name: String = .random, + id: Int = 1, + name: String = "Person Name", originalName: String, - knownForDepartment: String? = .random, + knownForDepartment: String? = nil, gender: Gender = .unknown, - profilePath: URL? = .randomImagePath, - popularity: Double? = Double.random(in: 1...10) + profilePath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + popularity: Double? = 5 ) -> Self { .init( id: id, diff --git a/Tests/TMDbTests/Mocks/Models/PersonMovieCredits+Mocks.swift b/Tests/TMDbTests/Mocks/Models/PersonMovieCredits+Mocks.swift index 4dc56c25..c68cc457 100644 --- a/Tests/TMDbTests/Mocks/Models/PersonMovieCredits+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/PersonMovieCredits+Mocks.swift @@ -23,7 +23,7 @@ import TMDb extension PersonMovieCredits { static func mock( - id: Int = .randomID, + id: Int = 1, cast: [Movie] = .mocks, crew: [Movie] = .mocks ) -> Self { diff --git a/Tests/TMDbTests/Mocks/Models/PersonPageableList+Mocks.swift b/Tests/TMDbTests/Mocks/Models/PersonPageableList+Mocks.swift index 96c5e961..e9dd6afc 100644 --- a/Tests/TMDbTests/Mocks/Models/PersonPageableList+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/PersonPageableList+Mocks.swift @@ -23,10 +23,10 @@ import TMDb extension PersonPageableList { static func mock( - page: Int = .random(in: 1...5), + page: Int = 1, results: [PersonListItem] = .mocks, - totalResults: Int = .random(in: 1...100), - totalPages: Int = .random(in: 1...5) + totalResults: Int = 10, + totalPages: Int = 2 ) -> Self { .init( page: page, diff --git a/Tests/TMDbTests/Mocks/Models/PersonTVSeriesCredits+Mocks.swift b/Tests/TMDbTests/Mocks/Models/PersonTVSeriesCredits+Mocks.swift index e6a94611..2d7ca080 100644 --- a/Tests/TMDbTests/Mocks/Models/PersonTVSeriesCredits+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/PersonTVSeriesCredits+Mocks.swift @@ -23,7 +23,7 @@ import TMDb extension PersonTVSeriesCredits { static func mock( - id: Int = .randomID, + id: Int = 1, cast: [TVSeries] = .mocks, crew: [TVSeries] = .mocks ) -> Self { diff --git a/Tests/TMDbTests/Mocks/Models/ProductionCompany+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ProductionCompany+Mocks.swift index deea83d1..1c37327e 100644 --- a/Tests/TMDbTests/Mocks/Models/ProductionCompany+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ProductionCompany+Mocks.swift @@ -23,14 +23,14 @@ import TMDb extension ProductionCompany { static func mock( - id: Int = .randomID, - name: String? = nil, - originCountry: String = .random, - logoPath: URL? = .randomImagePath + id: Int = 1, + name: String = "Production Company Name", + originCountry: String = "Production Origin Country", + logoPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")! ) -> Self { .init( id: id, - name: name ?? "Production Company \(id)", + name: name, originCountry: originCountry, logoPath: logoPath ) diff --git a/Tests/TMDbTests/Mocks/Models/ProductionCountry+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ProductionCountry+Mocks.swift index 719bdd1f..641de5f3 100644 --- a/Tests/TMDbTests/Mocks/Models/ProductionCountry+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ProductionCountry+Mocks.swift @@ -23,8 +23,8 @@ import TMDb extension ProductionCountry { static func mock( - countryCode: String = .random, - name: String = .random + countryCode: String = "US", + name: String = "United States of America" ) -> Self { .init( countryCode: countryCode, diff --git a/Tests/TMDbTests/Mocks/Models/Review+Mocks.swift b/Tests/TMDbTests/Mocks/Models/Review+Mocks.swift index 1695c17e..9a358944 100644 --- a/Tests/TMDbTests/Mocks/Models/Review+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/Review+Mocks.swift @@ -23,13 +23,13 @@ import TMDb extension Review { static func mock( - id: String = .randomID, - author: String? = nil, - content: String = .random + id: String = "1", + author: String = "Author Name", + content: String = "Some review content" ) -> Self { .init( id: id, - author: author ?? "Author \(String.randomID)", + author: author, content: content ) } diff --git a/Tests/TMDbTests/Mocks/Models/ReviewPageableList+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ReviewPageableList+Mocks.swift index f61ae623..92ddd8a8 100644 --- a/Tests/TMDbTests/Mocks/Models/ReviewPageableList+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ReviewPageableList+Mocks.swift @@ -23,10 +23,10 @@ import TMDb extension ReviewPageableList { static func mock( - page: Int = .random(in: 1...5), + page: Int = 1, results: [Review] = .mocks, - totalResults: Int = .random(in: 1...100), - totalPages: Int = .random(in: 1...5) + totalResults: Int = 10, + totalPages: Int = 2 ) -> Self { .init( page: page, diff --git a/Tests/TMDbTests/Mocks/Models/ShowCredits+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ShowCredits+Mocks.swift index 7b633a74..4b292f24 100644 --- a/Tests/TMDbTests/Mocks/Models/ShowCredits+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ShowCredits+Mocks.swift @@ -23,7 +23,7 @@ import TMDb extension ShowCredits { static func mock( - id: Int = .randomID, + id: Int = 1, cast: [CastMember] = .mocks, crew: [CrewMember] = .mocks ) -> Self { diff --git a/Tests/TMDbTests/Mocks/Models/ShowWatchProviderResult+Mocks.swift b/Tests/TMDbTests/Mocks/Models/ShowWatchProviderResult+Mocks.swift index f24c1f5d..e49d5e88 100644 --- a/Tests/TMDbTests/Mocks/Models/ShowWatchProviderResult+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/ShowWatchProviderResult+Mocks.swift @@ -24,7 +24,7 @@ import Foundation extension ShowWatchProviderResult { static func mock( - id: Int = .randomID, + id: Int = 1, regionCode: String = "GB" ) -> Self { .init( diff --git a/Tests/TMDbTests/Mocks/Models/SpokenLanguage+Mocks.swift b/Tests/TMDbTests/Mocks/Models/SpokenLanguage+Mocks.swift index b00d0950..ca9b6ec9 100644 --- a/Tests/TMDbTests/Mocks/Models/SpokenLanguage+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/SpokenLanguage+Mocks.swift @@ -23,8 +23,8 @@ import TMDb extension SpokenLanguage { static func mocks( - languageCode: String = .random, - name: String = .random + languageCode: String = "en", + name: String = "English" ) -> Self { .init( languageCode: languageCode, diff --git a/Tests/TMDbTests/Mocks/Models/TVEpisode+Mocks.swift b/Tests/TMDbTests/Mocks/Models/TVEpisode+Mocks.swift index 8840459a..9faaa26d 100644 --- a/Tests/TMDbTests/Mocks/Models/TVEpisode+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/TVEpisode+Mocks.swift @@ -23,12 +23,12 @@ import TMDb extension TVEpisode { static func mock( - id: Int = .randomID, - name: String? = nil, - episodeNumber: Int = .random(in: 0...23), - seasonNumber: Int = .random(in: 0...10), - overview: String? = .random, - airDate: Date? = .random, + id: Int = 1, + name: String = "TV Episode Name", + episodeNumber: Int = 3, + seasonNumber: Int = 2, + overview: String? = "Overview for TV Episode", + airDate: Date? = Date(iso8601: "2013-11-15T10:20:00Z"), productionCode: String? = nil, stillPath: URL? = nil, crew: [CrewMember]? = nil, @@ -38,7 +38,7 @@ extension TVEpisode { ) -> Self { .init( id: id, - name: name ?? "TV Episode \(id)", + name: name, episodeNumber: episodeNumber, seasonNumber: seasonNumber, overview: overview, diff --git a/Tests/TMDbTests/Mocks/Models/TVEpisodeImageCollection+Mocks.swift b/Tests/TMDbTests/Mocks/Models/TVEpisodeImageCollection+Mocks.swift index dead67bc..6a111251 100644 --- a/Tests/TMDbTests/Mocks/Models/TVEpisodeImageCollection+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/TVEpisodeImageCollection+Mocks.swift @@ -23,7 +23,7 @@ import TMDb extension TVEpisodeImageCollection { static func mock( - id: Int = .randomID, + id: Int = 1, stills: [ImageMetadata] = .mocks ) -> Self { .init( diff --git a/Tests/TMDbTests/Mocks/Models/TVSeason+Mock.swift b/Tests/TMDbTests/Mocks/Models/TVSeason+Mock.swift index 07be4ba3..f063b8fb 100644 --- a/Tests/TMDbTests/Mocks/Models/TVSeason+Mock.swift +++ b/Tests/TMDbTests/Mocks/Models/TVSeason+Mock.swift @@ -23,11 +23,11 @@ import TMDb extension TVSeason { static func mock( - id: Int = .randomID, + id: Int = 1, name: String? = nil, - seasonNumber: Int = Int.random(in: 1...10), - overview: String? = .random, - airDate: Date? = .random, + seasonNumber: Int = 2, + overview: String? = "TV Season Overview", + airDate: Date? = Date(iso8601: "2013-11-15T10:20:00Z"), posterPath: URL? = nil, episodes: [TVEpisode]? = .mocks ) -> Self { diff --git a/Tests/TMDbTests/Mocks/Models/TVSeasonImageCollection+Mocks.swift b/Tests/TMDbTests/Mocks/Models/TVSeasonImageCollection+Mocks.swift index a843bdc2..bceb7fb3 100644 --- a/Tests/TMDbTests/Mocks/Models/TVSeasonImageCollection+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/TVSeasonImageCollection+Mocks.swift @@ -23,7 +23,7 @@ import TMDb extension TVSeasonImageCollection { static func mock( - id: Int = .randomID, + id: Int = 1, posters: [ImageMetadata] = .mocks ) -> Self { .init( diff --git a/Tests/TMDbTests/Mocks/Models/TVSeries+Mocks.swift b/Tests/TMDbTests/Mocks/Models/TVSeries+Mocks.swift index 38731722..3e70d979 100644 --- a/Tests/TMDbTests/Mocks/Models/TVSeries+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/TVSeries+Mocks.swift @@ -24,17 +24,17 @@ import Foundation extension TVSeries { static func mock( - id: Int = .randomID, + id: Int = 1, name: String? = nil, originalName: String? = nil, originalLanguage: String? = nil, - overview: String? = .random, + overview: String? = "TV Series Overview", episodeRunTime: [Int]? = nil, numberOfSeasons: Int? = nil, numberOfEpisodes: Int? = nil, seasons: [TVSeason]? = nil, genres: [Genre]? = nil, - firstAirDate: Date? = .random, + firstAirDate: Date? = Date(iso8601: "2013-11-15T10:20:00Z"), originCountry: [String]? = nil, posterPath: URL? = nil, backdropPath: URL? = nil, diff --git a/Tests/TMDbTests/Mocks/Models/TVSeriesListItem+Mocks.swift b/Tests/TMDbTests/Mocks/Models/TVSeriesListItem+Mocks.swift index eea8509f..71848dee 100644 --- a/Tests/TMDbTests/Mocks/Models/TVSeriesListItem+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/TVSeriesListItem+Mocks.swift @@ -24,19 +24,19 @@ import Foundation extension TVSeriesListItem { static func mock( - id: Int = .randomID, + id: Int = 1, name: String = "TV Series", originalName: String = "TV Series a", originalLanguage: String = "en", - overview: String = .random, + overview: String = "TV Series Overview", genreIDs: [Genre.ID] = [1], firstAirDate: Date? = nil, originCountries: [String] = ["GB"], - posterPath: URL? = .randomImagePath, - backdropPath: URL? = .randomImagePath, - popularity: Double? = Double.random(in: 1...10), - voteAverage: Double? = Double.random(in: 1...10), - voteCount: Int? = Int.random(in: 1...1000), + posterPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + backdropPath: URL? = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")!, + popularity: Double? = 5, + voteAverage: Double? = 5, + voteCount: Int? = 100, isAdultOnly: Bool? = false ) -> TVSeriesListItem { TVSeriesListItem( diff --git a/Tests/TMDbTests/Mocks/Models/TVSeriesPageableList+Mocks.swift b/Tests/TMDbTests/Mocks/Models/TVSeriesPageableList+Mocks.swift index 4045ab11..1d2d6ae2 100644 --- a/Tests/TMDbTests/Mocks/Models/TVSeriesPageableList+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/TVSeriesPageableList+Mocks.swift @@ -23,10 +23,10 @@ import TMDb extension TVSeriesPageableList { static func mock( - page: Int = Int.random(in: 1...5), + page: Int = 1, results: [TVSeriesListItem] = .mocks, - totalResults: Int? = Int.random(in: 1...100), - totalPages: Int? = Int.random(in: 1...5) + totalResults: Int? = 10, + totalPages: Int? = 2 ) -> Self { .init( page: page, diff --git a/Tests/TMDbTests/Mocks/Models/VideoCollection+Mocks.swift b/Tests/TMDbTests/Mocks/Models/VideoCollection+Mocks.swift index 506d7c1b..b376b2e3 100644 --- a/Tests/TMDbTests/Mocks/Models/VideoCollection+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/VideoCollection+Mocks.swift @@ -23,7 +23,7 @@ import TMDb extension VideoCollection { static func mock( - id: Int = .randomID, + id: Int = 1, results: [VideoMetadata] = .mocks ) -> Self { .init( diff --git a/Tests/TMDbTests/Mocks/Models/VideoMetadata+Mocks.swift b/Tests/TMDbTests/Mocks/Models/VideoMetadata+Mocks.swift index b3a182f2..57412912 100644 --- a/Tests/TMDbTests/Mocks/Models/VideoMetadata+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/VideoMetadata+Mocks.swift @@ -23,8 +23,8 @@ import TMDb extension VideoMetadata { static func mock( - id: String = .randomID, - name: String = .random, + id: String = "1", + name: String = "Video name", site: String = "YouTube", key: String = "abc123", type: VideoType = .trailer, diff --git a/Tests/TMDbTests/Mocks/Models/WatchProvider+Mocks.swift b/Tests/TMDbTests/Mocks/Models/WatchProvider+Mocks.swift index c12fdce9..bc117b22 100644 --- a/Tests/TMDbTests/Mocks/Models/WatchProvider+Mocks.swift +++ b/Tests/TMDbTests/Mocks/Models/WatchProvider+Mocks.swift @@ -23,8 +23,8 @@ import TMDb extension WatchProvider { static func mock( - id: Int = .randomID, - name: String = .random, + id: Int = 1, + name: String = "Netflix", logoPath: URL = URL(string: "/t2yyOv40HZeVlLjYsCsPHnWLk4W.jpg")! ) -> Self { .init( diff --git a/Tests/TMDbTests/Mocks/URL+Mocks.swift b/Tests/TMDbTests/Mocks/URL+Mocks.swift deleted file mode 100644 index e321d2e6..00000000 --- a/Tests/TMDbTests/Mocks/URL+Mocks.swift +++ /dev/null @@ -1,39 +0,0 @@ -// -// URL+Mocks.swift -// TMDb -// -// Copyright © 2024 Adam Young. -// -// 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. -// - -import Foundation - -extension URL { - - static var randomImagePath: URL { - URL(string: "/\(String.random).jpg")! - } - - static var randomWebSite: URL { - URL(string: "https://www.\(String.random).com")! - } - - static func randomBaseURL(secure: Bool = true) -> URL { - URL( - string: - "\(secure ? "https" : "http")://api.\(String.random).com/\(String.random)/" - )! - } - -} diff --git a/Tests/TMDbTests/TestUtils/Date+RandomDate.swift b/Tests/TMDbTests/TestUtils/Date+ISO8601.swift similarity index 70% rename from Tests/TMDbTests/TestUtils/Date+RandomDate.swift rename to Tests/TMDbTests/TestUtils/Date+ISO8601.swift index 312e44cc..79a38748 100644 --- a/Tests/TMDbTests/TestUtils/Date+RandomDate.swift +++ b/Tests/TMDbTests/TestUtils/Date+ISO8601.swift @@ -1,5 +1,5 @@ // -// Date+RandomDate.swift +// Date+ISO8601.swift // TMDb // // Copyright © 2024 Adam Young. @@ -21,10 +21,13 @@ import Foundation extension Date { - static var random: Self { - let date = Date().timeIntervalSince1970 - let timeInterval = Double.random(in: 1_118_839_159...date) - return Date(timeIntervalSince1970: timeInterval) + init(iso8601 dateString: String) { + let formatter = ISO8601DateFormatter() + guard let date = formatter.date(from: dateString) else { + fatalError("Invalid ISO8601 date string: \(dateString)") + } + + self = date } } diff --git a/Tests/TMDbTests/TestUtils/Int+RandomID.swift b/Tests/TMDbTests/TestUtils/Int+RandomID.swift deleted file mode 100644 index f4b14929..00000000 --- a/Tests/TMDbTests/TestUtils/Int+RandomID.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// Int+RandomID.swift -// TMDb -// -// Copyright © 2024 Adam Young. -// -// 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. -// - -import Foundation - -extension Int { - - static var randomID: Self { - .random(in: 1...10_000_000) - } - -} diff --git a/Tests/TMDbTests/TestUtils/JSONEncoder+TMDb.swift b/Tests/TMDbTests/TestUtils/JSONEncoder+TMDb.swift deleted file mode 100644 index edf83c44..00000000 --- a/Tests/TMDbTests/TestUtils/JSONEncoder+TMDb.swift +++ /dev/null @@ -1,54 +0,0 @@ -// -// JSONEncoder+TMDb.swift -// TMDb -// -// Copyright © 2024 Adam Young. -// -// 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. -// - -//// -//// JSONEncoder+TMDb.swift -//// TMDb -//// -//// Copyright © 2024 Adam Young. -//// -//// 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. -//// -// -// import Foundation -// import TMDb -// -// extension JSONEncoder { -// -// static var theMovieDatabase: JSONEncoder { -// let dateFormatter = DateFormatter() -// dateFormatter.dateFormat = "yyyy-MM-dd" -// -// let encoder = JSONEncoder() -// encoder.keyEncodingStrategy = .convertToSnakeCase -// encoder.dateEncodingStrategy = .formatted(dateFormatter) -// return encoder -// } -// -// } diff --git a/Tests/TMDbTests/TestUtils/String+RandomID.swift b/Tests/TMDbTests/TestUtils/String+RandomID.swift deleted file mode 100644 index 8cf16f9b..00000000 --- a/Tests/TMDbTests/TestUtils/String+RandomID.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// String+RandomID.swift -// TMDb -// -// Copyright © 2024 Adam Young. -// -// 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. -// - -import Foundation - -extension String { - - static var randomID: Self { - String(Int.randomID) - } - - static var random: Self { - UUID().uuidString - } - -}