diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 231af35c..0009f967 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,13 +58,13 @@ jobs: matrix: include: - name: iOS - destination: platform=iOS Simulator,name=iPhone 15,OS=17.5 + destination: platform=iOS Simulator,name=iPhone 15,OS=18.0 - name: watchOS - destination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.5 + destination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=11.0 - name: tvOS - destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.5 + destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=18.0 - name: visionOS - destination: platform=visionOS Simulator,name=Apple Vision Pro,OS=1.2 + destination: platform=visionOS Simulator,name=Apple Vision Pro,OS=2.0 steps: - name: Checkout uses: actions/checkout@v4 diff --git a/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonAggregateCreditsRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonAggregateCreditsRequestTests.swift index cf9b85ff..1a09d96a 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonAggregateCreditsRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonAggregateCreditsRequestTests.swift @@ -17,45 +17,53 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeasonAggregateCreditsRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeason)) +struct TVSeasonAggregateCreditsRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = TVSeasonAggregateCreditsRequest(seasonNumber: 2, tvSeriesID: 1) - XCTAssertEqual(request.path, "/tv/1/season/2/aggregate_credits") + #expect(request.path == "/tv/1/season/2/aggregate_credits") } - func testQueryItemsIsEmpty() { + @Test("queryItems is empty") + func queryItemsIsEmpty() { let request = TVSeasonAggregateCreditsRequest(seasonNumber: 2, tvSeriesID: 1) - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithLanguage() { + @Test("queryItems with language") + func queryItemsWithLanguage() { let request = TVSeasonAggregateCreditsRequest(seasonNumber: 2, tvSeriesID: 1, language: "en") - XCTAssertEqual(request.queryItems, ["language": "en"]) + #expect(request.queryItems == ["language": "en"]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = TVSeasonAggregateCreditsRequest(seasonNumber: 2, tvSeriesID: 1) - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = TVSeasonAggregateCreditsRequest(seasonNumber: 2, tvSeriesID: 1) - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = TVSeasonAggregateCreditsRequest(seasonNumber: 2, tvSeriesID: 1) - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonImagesRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonImagesRequestTests.swift index aedc2e18..3229375f 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonImagesRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonImagesRequestTests.swift @@ -17,45 +17,53 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeasonImagesRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeason)) +struct TVSeasonImagesRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = TVSeasonImagesRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertEqual(request.path, "/tv/3/season/2/images") + #expect(request.path == "/tv/3/season/2/images") } - func testQueryItemsIsEmpty() { + @Test("queryItems is empty") + func queryItemsIsEmpty() { let request = TVSeasonImagesRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithLanguages() { + @Test("queryItems with languages") + func queryItemsWithLanguages() { let request = TVSeasonImagesRequest(seasonNumber: 2, tvSeriesID: 3, languages: ["en-GB", "fr"]) - XCTAssertEqual(request.queryItems, ["include_image_language": "en,fr,null"]) + #expect(request.queryItems == ["include_image_language": "en,fr,null"]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = TVSeasonImagesRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = TVSeasonImagesRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = TVSeasonImagesRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonRequestTests.swift index 9811677e..f6b66bff 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonRequestTests.swift @@ -17,44 +17,53 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeasonRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeason)) +struct TVSeasonRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = TVSeasonRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertEqual(request.path, "/tv/3/season/2") + + #expect(request.path == "/tv/3/season/2") } - func testQueryItemsIsEmpty() { + @Test("queryItems is empty") + func queryItemsIsEmpty() { let request = TVSeasonRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithLanguage() { + @Test("queryItems with language") + func queryItemsWithLanguage() { let request = TVSeasonRequest(seasonNumber: 2, tvSeriesID: 3, language: "en") - XCTAssertEqual(request.queryItems, ["language": "en"]) + #expect(request.queryItems == ["language": "en"]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = TVSeasonRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = TVSeasonRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = TVSeasonRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonVideosRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonVideosRequestTests.swift index 1d990ef3..79f170e6 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonVideosRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeasons/Requests/TVSeasonVideosRequestTests.swift @@ -17,45 +17,53 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeasonVideosRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeason)) +struct TVSeasonVideosRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = TVSeasonVideosRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertEqual(request.path, "/tv/3/season/2/videos") + #expect(request.path == "/tv/3/season/2/videos") } - func testQueryItemsIsEmpty() { + @Test("queryItems is empty") + func queryItemsIsEmpty() { let request = TVSeasonVideosRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithLanguages() { + @Test("queryItems with languages") + func queryItemsWithLanguages() { let request = TVSeasonVideosRequest(seasonNumber: 2, tvSeriesID: 3, languages: ["en-GB", "fr"]) - XCTAssertEqual(request.queryItems["include_video_language"], "en-GB,fr") + #expect(request.queryItems == ["include_video_language": "en-GB,fr"]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = TVSeasonVideosRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = TVSeasonVideosRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = TVSeasonVideosRequest(seasonNumber: 2, tvSeriesID: 3) - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeasons/TMDbTVSeasonServiceTests.swift b/Tests/TMDbTests/Domain/Services/TVSeasons/TMDbTVSeasonServiceTests.swift index 6843f088..da343fc9 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeasons/TMDbTVSeasonServiceTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeasons/TMDbTVSeasonServiceTests.swift @@ -17,27 +17,23 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TMDbTVSeasonServiceTests: XCTestCase { +@Suite(.tags(.services, .tvSeason)) +struct TMDbTVSeasonServiceTests { var service: TMDbTVSeasonService! var apiClient: MockAPIClient! - override func setUp() { - super.setUp() - apiClient = MockAPIClient() - service = TMDbTVSeasonService(apiClient: apiClient) + init() { + self.apiClient = MockAPIClient() + self.service = TMDbTVSeasonService(apiClient: apiClient) } - override func tearDown() { - apiClient = nil - service = nil - super.tearDown() - } - - func testDetailsReturnsTVSeason() async throws { + @Test("details returns TV season") + func detailsReturnsTVSeason() async throws { let tvSeriesID = Int.randomID let expectedResult = TVSeason.mock() let seasonNumber = expectedResult.seasonNumber @@ -50,11 +46,12 @@ final class TMDbTVSeasonServiceTests: XCTestCase { let result = try await service.details(forSeason: seasonNumber, inTVSeries: tvSeriesID) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeasonRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeasonRequest == expectedRequest) } - func testDetailsWithLanguageReturnsTVSeason() async throws { + @Test("details with language returns TV season") + func detailsWithLanguageReturnsTVSeason() async throws { let tvSeriesID = Int.randomID let expectedResult = TVSeason.mock() let seasonNumber = expectedResult.seasonNumber @@ -68,28 +65,23 @@ final class TMDbTVSeasonServiceTests: XCTestCase { let result = try await service.details(forSeason: seasonNumber, inTVSeries: tvSeriesID, language: language) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeasonRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeasonRequest == expectedRequest) } - func testDetailsWhenErrorsThrowsError() async throws { + @Test("details when errors throws error") + func detailsWhenErrorsThrowsError() async throws { let tvSeriesID = 1 let seasonNumber = 2 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.details(forSeason: seasonNumber, inTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } - func testAggregateCreditsReturnsTVSeasonCredits() async throws { + @Test("aggregateCredits returns TV season credits") + func aggregateCreditsReturnsTVSeasonCredits() async throws { let tvSeriesID = Int.randomID let expectedResult = TVSeasonAggregateCredits(id: 1, cast: [], crew: []) let seasonNumber = Int.randomID @@ -102,11 +94,12 @@ final class TMDbTVSeasonServiceTests: XCTestCase { let result = try await service.aggregateCredits(forSeason: seasonNumber, inTVSeries: tvSeriesID) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeasonAggregateCreditsRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeasonAggregateCreditsRequest == expectedRequest) } - func testAggregateCreditsWithLanguageReturnsTVSeasonCredits() async throws { + @Test("aggregateCredits with language returns TV season credits") + func aggregateCreditsWithLanguageReturnsTVSeasonCredits() async throws { let tvSeriesID = Int.randomID let expectedResult = TVSeasonAggregateCredits(id: 1, cast: [], crew: []) let seasonNumber = Int.randomID @@ -124,28 +117,23 @@ final class TMDbTVSeasonServiceTests: XCTestCase { language: language ) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeasonAggregateCreditsRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeasonAggregateCreditsRequest == expectedRequest) } - func testAggregateCreditsWhenErrorsThrowsError() async throws { + @Test("aggregateCredits when errors throws error") + func aggregateCreditsWhenErrorsThrowsError() async throws { let tvSeriesID = 1 let seasonNumber = 2 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.aggregateCredits(forSeason: seasonNumber, inTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } - func testImagesReturnsImages() async throws { + @Test("imagess returns images") + func imagesReturnsImages() async throws { let seasonNumber = Int.randomID let tvSeriesID = Int.randomID let expectedResult = TVSeasonImageCollection.mock() @@ -158,11 +146,12 @@ final class TMDbTVSeasonServiceTests: XCTestCase { let result = try await service.images(forSeason: seasonNumber, inTVSeries: tvSeriesID) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeasonImagesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeasonImagesRequest == expectedRequest) } - func testImagesWithFilterReturnsImages() async throws { + @Test("images with filter returns images") + func imagesWithFilterReturnsImages() async throws { let seasonNumber = Int.randomID let tvSeriesID = Int.randomID let languages = ["en-GB", "fr"] @@ -177,28 +166,23 @@ final class TMDbTVSeasonServiceTests: XCTestCase { let filter = TVSeasonImageFilter(languages: languages) let result = try await service.images(forSeason: seasonNumber, inTVSeries: tvSeriesID, filter: filter) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeasonImagesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeasonImagesRequest == expectedRequest) } - func testImagesWhenErrorsThrowsError() async throws { + @Test("images when errors throws error") + func imagesWhenErrorsThrowsError() async throws { let tvSeriesID = 1 let seasonNumber = 2 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.images(forSeason: seasonNumber, inTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } - func testVideosReturnsVideos() async throws { + @Test("videos returns videos") + func videosReturnsVideos() async throws { let seasonNumber = Int.randomID let tvSeriesID = Int.randomID let expectedResult = VideoCollection.mock() @@ -211,11 +195,12 @@ final class TMDbTVSeasonServiceTests: XCTestCase { let result = try await service.videos(forSeason: seasonNumber, inTVSeries: tvSeriesID) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeasonVideosRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeasonVideosRequest == expectedRequest) } - func testVideosWithFilterReturnsVideos() async throws { + @Test("videos with filter returns videos") + func videosWithFilterReturnsVideos() async throws { let seasonNumber = Int.randomID let tvSeriesID = Int.randomID let languages = ["en", "fr"] @@ -230,25 +215,19 @@ final class TMDbTVSeasonServiceTests: XCTestCase { let filter = TVSeasonVideoFilter(languages: languages) let result = try await service.videos(forSeason: seasonNumber, inTVSeries: tvSeriesID, filter: filter) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeasonVideosRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeasonVideosRequest == expectedRequest) } - func testVideosWhenErrorsThrowsError() async throws { + @Test("videos when errors throws error") + func videosWhenErrorsThrowsError() async throws { let tvSeriesID = 1 let seasonNumber = 2 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.videos(forSeason: seasonNumber, inTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } }