Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MartinP7r opened this issue Jan 10, 2024 · 1 comment

Comments

@MartinP7r
Copy link
Collaborator

MartinP7r commented Jan 10, 2024

@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`
    }
@MartinP7r
Copy link
Collaborator Author

Also, MovieMDB.movie(...) returning MovieDetailedMDB is a bit confusing to me.

public static func movie(movieID: Int!, language: String? = nil, completion: @escaping (_ clientReturn: ClientReturn, _ data: MovieDetailedMDB?) -> Void) {

Is there some documentation for this? Where can we access the DocC documentation that's being generated on each merge? Maybe a link in the readme would be helpful 🙏🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant