Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
adamayoung committed Sep 12, 2024
1 parent ff8a641 commit df7c2da
Show file tree
Hide file tree
Showing 18 changed files with 186 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
build-test-linux:
name: Build and Test (Linux)
runs-on: ubuntu-latest
container: swift:5.9.2-jammy
container: swiftlang/swift:nightly-6.0-jammy
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WATCHOS_DESINTATION = 'platform=watchOS Simulator,name=Apple Watch Series 9 (45m
TVOS_DESTINATION = 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=18.0'
VISIONOS_DESTINATION = 'platform=visionOS Simulator,name=Apple Vision Pro,OS=2.0'

SWIFT_CONTAINER_IMAGE = swift:5.9.2-jammy
SWIFT_CONTAINER_IMAGE = swiftlang/swift:nightly-6.0-jammy

.PHONY: clean
clean:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class TVSeasonAggregateCreditsTests: XCTestCase {
@Suite(.tags(.models))
struct TVSeasonAggregateCreditsTests {

func testDecodeReturnsTVSeasonAggregateCredits() throws {
@Test("JSON decoding of TVSeasonAggregateCredits", .tags(.decoding))
func decodeReturnsTVSeasonAggregateCredits() throws {
let result = try JSONDecoder.theMovieDatabase.decode(
TVSeriesAggregateCredits.self,
fromResource: "tv-season-aggregate-credits"
)

XCTAssertEqual(result.id, 3625)
XCTAssertEqual(result.cast.count, 3)
XCTAssertEqual(result.crew.count, 2)
#expect(result.id == 3625)
#expect(result.cast.count == 3)
#expect(result.crew.count == 2)
}

}
23 changes: 13 additions & 10 deletions Tests/TMDbTests/Domain/Models/TVSeasonTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class TVSeasonTests: XCTestCase {
@Suite(.tags(.models))
struct TVSeasonTests {

func testDecodeReturnsTVSeason() throws {
@Test("JSON decoding of TVSeason", .tags(.decoding))
func decodeReturnsTVSeason() throws {
let result = try JSONDecoder.theMovieDatabase.decode(TVSeason.self, fromResource: "tv-season")

XCTAssertEqual(result.id, tvSeason.id)
XCTAssertEqual(result.name, tvSeason.name)
XCTAssertEqual(result.seasonNumber, tvSeason.seasonNumber)
XCTAssertEqual(result.overview, tvSeason.overview)
XCTAssertEqual(result.airDate, tvSeason.airDate)
XCTAssertEqual(result.posterPath, tvSeason.posterPath)
XCTAssertEqual(result.episodes, tvSeason.episodes)
#expect(result.id == tvSeason.id)
#expect(result.name == tvSeason.name)
#expect(result.seasonNumber == tvSeason.seasonNumber)
#expect(result.overview == tvSeason.overview)
#expect(result.airDate == tvSeason.airDate)
#expect(result.posterPath == tvSeason.posterPath)
#expect(result.episodes == tvSeason.episodes)
}

// swiftlint:disable line_length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class TVSeriesAggregateCreditsTests: XCTestCase {
@Suite(.tags(.models))
struct TVSeriesAggregateCreditsTests {

func testDecodeReturnsTVSeriesAggregateCredits() throws {
@Test("JSON decoding of TVSeriesAggregateCredits", .tags(.decoding))
func decodeReturnsTVSeriesAggregateCredits() throws {
let result = try JSONDecoder.theMovieDatabase.decode(
TVSeriesAggregateCredits.self,
fromResource: "tv-series-aggregate-credits"
)

XCTAssertEqual(result.id, 4604)
XCTAssertEqual(result.cast.count, 4)
XCTAssertEqual(result.crew.count, 2)
#expect(result.id == 4604)
#expect(result.cast.count == 4)
#expect(result.crew.count == 2)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class TVSeriesExternalLinksCollectionTests: XCTestCase {
@Suite(.tags(.models))
struct TVSeriesExternalLinksCollectionTests {

func testDecodeReturnsMovieExternalLinksCollection() throws {
@Test("JSON decoding of TVSeriesExternalLinksCollection", .tags(.decoding))
func decodeReturnsMovieExternalLinksCollection() throws {
let expectedResult = TVSeriesExternalLinksCollection(
id: 86423,
imdb: IMDbLink(imdbTitleID: "tt3007572"),
Expand All @@ -37,10 +40,11 @@ final class TVSeriesExternalLinksCollectionTests: XCTestCase {
fromResource: "tv-series-external-ids"
)

XCTAssertEqual(result, expectedResult)
#expect(result == expectedResult)
}

func testEncodeAndDecodeReturnsMovieExternalLinksCollection() throws {
@Test("JSON encoding and decoding of TVSeriesExternalLinksCollection", .tags(.decoding))
func encodeAndDecodeReturnsMovieExternalLinksCollection() throws {
let linksCollection = TVSeriesExternalLinksCollection(
id: 86423,
imdb: IMDbLink(imdbTitleID: "tt3007572"),
Expand All @@ -54,7 +58,7 @@ final class TVSeriesExternalLinksCollectionTests: XCTestCase {

let result = try JSONDecoder.theMovieDatabase.decode(TVSeriesExternalLinksCollection.self, from: data)

XCTAssertEqual(result, linksCollection)
#expect(result == linksCollection)
}

}
11 changes: 7 additions & 4 deletions Tests/TMDbTests/Domain/Models/TVSeriesListItemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class TVSeriesListItemTests: XCTestCase {
@Suite(.tags(.models))
struct TVSeriesListItemTests {

func testDecodeReturnsTVSeriesListItem() throws {
@Test("JSON decoding of TVSeriesListItem", .tags(.decoding))
func decodeReturnsTVSeriesListItem() throws {
let result = try JSONDecoder.theMovieDatabase.decode(TVSeriesListItem.self, fromResource: "tv-series-list-item")

XCTAssertEqual(result, tvSeries)
#expect(result == tvSeries)
}

}
Expand Down
17 changes: 10 additions & 7 deletions Tests/TMDbTests/Domain/Models/TVSeriesPageableListTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class TVSeriesPageableListTests: XCTestCase {
@Suite(.tags(.models))
struct TVSeriesPageableListTests {

func testDecodeReturnsTVSeriesPageableList() throws {
@Test("JSON decoding of TVSeriesPageableList", .tags(.decoding))
func decodeReturnsTVSeriesPageableList() throws {
let result = try JSONDecoder.theMovieDatabase
.decode(TVSeriesPageableList.self, fromResource: "tv-series-pageable-list")

XCTAssertEqual(result.page, list.page)
XCTAssertEqual(result.results, list.results)
XCTAssertEqual(result.totalResults, list.totalResults)
XCTAssertEqual(result.totalPages, list.totalPages)
#expect(result.page == list.page)
#expect(result.results == list.results)
#expect(result.totalResults == list.totalResults)
#expect(result.totalPages == list.totalPages)
}

// swiftlint:disable line_length
Expand Down
18 changes: 11 additions & 7 deletions Tests/TMDbTests/Domain/Models/TVSeriesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,29 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class TVSeriesTests: XCTestCase {
@Suite(.tags(.models))
struct TVSeriesTests {

func testDecodeReturnsTVSeries() throws {
@Test("JSON decoding of TVSeries", .tags(.decoding))
func decodeReturnsTVSeries() throws {
let result = try JSONDecoder.theMovieDatabase.decode(TVSeries.self, fromResource: "tv-series")

XCTAssertEqual(result, tvSeries)
#expect(result == tvSeries)
}

func testDecodeWhenHomepageIsEmptyStringReturnsTVSeries() throws {
@Test("JSON decoding of TVSeries with blank homepage and first air date")
func decodeWhenHomepageIsEmptyStringReturnsTVSeries() throws {
let result = try JSONDecoder.theMovieDatabase.decode(
TVSeries.self,
fromResource: "tv-series-blank-homepage-first-air-date"
)

XCTAssertNil(result.homepageURL)
XCTAssertNil(result.firstAirDate)
#expect(result.homepageURL == nil)
#expect(result.firstAirDate == nil)
}

}
Expand Down
22 changes: 14 additions & 8 deletions Tests/TMDbTests/Domain/Models/TwitterLinkTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,28 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class TwitterLinkTests: XCTestCase {
@Suite(.tags(.models))
struct TwitterLinkTests {

func testInitWithTwitterIDWhenIDIsNilReturnsNil() {
XCTAssertNil(TwitterLink(twitterID: nil))
@Test("init with twitterID when ID is nil returns nil")
func initWithTwitterIDWhenIDIsNilReturnsNil() {
let twitterLint = TwitterLink(twitterID: nil)

#expect(twitterLint == nil)
}

func testURL() throws {
@Test("url returns Twitter URL")
func urlReturnsTwitterURL() throws {
let twitterID = "barbiethemovie"
let expectedURL = try XCTUnwrap(URL(string: "https://www.twitter.com/\(twitterID)"))
let expectedURL = try #require(URL(string: "https://www.twitter.com/\(twitterID)"))

let twitterLink = TwitterLink(twitterID: twitterID)
let twitterLink = try #require(TwitterLink(twitterID: twitterID))

XCTAssertEqual(twitterLink?.url, expectedURL)
#expect(twitterLink.url == expectedURL)
}

}
13 changes: 8 additions & 5 deletions Tests/TMDbTests/Domain/Models/VideoCollectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class VideoCollectionTests: XCTestCase {
@Suite(.tags(.models))
struct VideoCollectionTests {

func testDecodeReturnsVideoCollection() throws {
@Test("JSON decoding of VideoCollection", .tags(.decoding))
func decodeReturnsVideoCollection() throws {
let result = try JSONDecoder.theMovieDatabase.decode(VideoCollection.self, fromResource: "video-collection")

XCTAssertEqual(result.id, videoCollection.id)
XCTAssertEqual(result.results, videoCollection.results)
#expect(result.id == videoCollection.id)
#expect(result.results == videoCollection.results)
}

private let videoCollection = VideoCollection(
Expand Down
21 changes: 12 additions & 9 deletions Tests/TMDbTests/Domain/Models/VideoMetadataTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class VideoMetadataTests: XCTestCase {
@Suite(.tags(.models))
struct VideoMetadataTests {

func testDecodeReturnsVideoCollection() throws {
@Test("JSON decoding of VideoMetadata", .tags(.decoding))
func decodeReturnsVideoCollection() throws {
let result = try JSONDecoder.theMovieDatabase.decode(VideoMetadata.self, fromResource: "video-metadata")

XCTAssertEqual(result.id, videoMetadata.id)
XCTAssertEqual(result.name, videoMetadata.name)
XCTAssertEqual(result.site, videoMetadata.site)
XCTAssertEqual(result.key, videoMetadata.key)
XCTAssertEqual(result.type, videoMetadata.type)
XCTAssertEqual(result.size, videoMetadata.size)
#expect(result.id == videoMetadata.id)
#expect(result.name == videoMetadata.name)
#expect(result.site == videoMetadata.site)
#expect(result.key == videoMetadata.key)
#expect(result.type == videoMetadata.type)
#expect(result.size == videoMetadata.size)
}

private let videoMetadata = VideoMetadata(
Expand Down
29 changes: 18 additions & 11 deletions Tests/TMDbTests/Domain/Models/VideoSizeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,41 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class VideoSizeTests: XCTestCase {
@Suite(.tags(.models))
struct VideoSizeTests {

func test360VideoSizeReturnsRawValue() {
XCTAssertEqual(VideoSize.s360.rawValue, 360)
@Test("s360 video size rawValue is 360")
func s360VideoSizeReturnsRawValue() {
#expect(VideoSize.s360.rawValue == 360)
}

func test480VideoSizeReturnsRawValue() {
XCTAssertEqual(VideoSize.s480.rawValue, 480)
@Test("s480 video size rawValue is 480")
func s480VideoSizeReturnsRawValue() {
#expect(VideoSize.s480.rawValue == 480)
}

func test720VideoSizeReturnsRawValue() {
XCTAssertEqual(VideoSize.s720.rawValue, 720)
@Test("s720 video size rawValue is 720")
func s720VideoSizeReturnsRawValue() {
#expect(VideoSize.s720.rawValue == 720)
}

func test1080VideoSizeReturnsRawValue() {
XCTAssertEqual(VideoSize.s1080.rawValue, 1080)
@Test("s1080 video size rawValue is 1080")
func s1080VideoSizeReturnsRawValue() {
#expect(VideoSize.s1080.rawValue == 1080)
}

@Test("JSON decoding of VideoSize", .tags(.decoding))
func testDecodeWhenInvalidValueReturnsUnknown() throws {
let data = Data("{\"videoSize\": 999}".utf8)
let decoder = JSONDecoder()

let result = try decoder.decode(MockObject.self, from: data).videoSize

XCTAssertEqual(result, .unknown)
#expect(result == .unknown)
}

}
Expand Down
Loading

0 comments on commit df7c2da

Please sign in to comment.