Skip to content

MoveDetailedMDB.movie(...) (and MovieMDB.movie(...) ?) not working as expected #111

@MartinP7r

Description

@MartinP7r

@gkye @djpearce
Sorry to bother you.
I'm not sure I understand the data structure for these nested types correctly, but imdb_id (and others) seem to not be decoding correctly.

First of all, it's a string in json and the prop is Int!

I augmented tests below to confirm. Let me open a PR soon.

func testMovieById() {
var data: MovieDetailedMDB?
let expectation = self.expectation(description: "Wait for data to load.")
MovieMDB.movie(movieID: 7984) { _, movie in
data = movie
expectation.fulfill()
}
waitForExpectations(timeout: expecationTimeout, handler: nil)
XCTAssertNotNil(data)
XCTAssertEqual(data?.title, "In the Name of the Father")
}

    func testMovieById() {
        var data: MovieDetailedMDB?
        let expectation = self.expectation(description: "Wait for data to load.")

        MovieMDB.movie(movieID: 7984) { ddd, movie in
            debugPrint(String(data: ddd.data!, encoding: .utf8))
            data = movie
            expectation.fulfill()
        }
        waitForExpectations(timeout: expectationTimeout, handler: nil)
        XCTAssertNotNil(data)
        XCTAssertEqual(data?.title, "In the Name of the Father")
        XCTAssertEqual(data?.imdb_id, "tt0107207") // fails `nil`
        XCTAssertEqual(data?.homepage, "") // fails `nil`
        XCTAssertEqual(data?.runtime, 133) // fails `nil`
    }

    func testMovieDetailById() {
        var data: MovieDetailedMDB?
        let expectation = self.expectation(description: "Wait for data to load.")

        MovieDetailedMDB.movie(movieID: 7984) { ddd, movie in
            debugPrint(String(data: ddd.data!, encoding: .utf8))
            data = movie
            expectation.fulfill()
        }
        waitForExpectations(timeout: expectationTimeout, handler: nil)
        XCTAssertNotNil(data)
        XCTAssertEqual(data?.title, "In the Name of the Father")
        XCTAssertEqual(data?.imdb_id, "tt0107207") // fails `nil`
        XCTAssertEqual(data?.homepage, "") // fails `nil`
        XCTAssertEqual(data?.runtime, 133) // fails `nil`
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions