kean / Get

Web API client built using async/await
MIT License
937 stars 74 forks source link

_testGitHubUserApi() only passes with passes with "lean" user #4

Closed briviere closed 2 years ago

briviere commented 2 years ago

If I try to lookup a different api.github.com/users/briviere the test fails with the following within the APIClient.Serializer.decode actor:

test case:

final class APIClientIntegrationTests: XCTestCase { var sut: APIClient!

override func setUp() {
    super.setUp()

    sut = APIClient(host: "api.github.com")
}

func testGitHubUsersApi() async throws {
    let user = try await sut.send(Resources.users("briviere").get)

    print(user)

    XCTAssertEqual(user.login, "briviere")
}

}

Exception:

Printing description of data: ▿ 1282 bytes

kean commented 2 years ago

Did you extend a User type in any way? I'm seeing a similar error when I attempt to decode Date without passing a decoding strategy. I'll provide a way to inject the strategy.

vox-humana commented 2 years ago

I think the reason here is that User response doesn't follow GitHub API definition. For the mentioned briviere user hireable field is null. See #5

briviere commented 2 years ago

Thanks, #5 has resolved this issue.