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

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

Closed
briviere opened this issue Nov 27, 2021 · 3 comments · Fixed by #5
Closed

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

briviere opened this issue Nov 27, 2021 · 3 comments · Fixed by #5

Comments

@briviere
Copy link

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

  • count : 1282
    ▿ pointer : 0x00007f781283e200
    • pointerValue : 140153683436032
      Printing description of self:
      <Serializer: 0x600001e38af0>
      2021-11-27 10:17:08.571713-0500 xctest[77569:5961128] NSInvalidUnarchiveOperationException attempting to serialize associated error of issue: This decoder will only decode classes that adopt NSSecureCoding. Class '__SwiftValue' does not adopt it.
      :0: error: -[APIClientTests.APIClientIntegrationTests testGitHubUsersApi] : failed: caught error: "The data couldn’t be read because it is missing."
      Test Case '-[APIClientTests.APIClientIntegrationTests testGitHubUsersApi]' failed (106.243 seconds).
      Test Suite 'APIClientIntegrationTests' failed at 2021-11-27 10:17:08.573.
      Executed 1 test, with 1 failure (1 unexpected) in 106.243 (106.244) seconds
      Test Suite 'APIClientTests.xctest' failed at 2021-11-27 10:17:08.574.
      Executed 1 test, with 1 failure (1 unexpected) in 106.243 (106.245) seconds
      Test Suite 'Selected tests' failed at 2021-11-27 10:17:08.574.
      Executed 1 test, with 1 failure (1 unexpected) in 106.243 (106.247) seconds
      Program ended with exit code: 1
@kean
Copy link
Owner

kean commented Nov 28, 2021

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
Copy link
Contributor

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
Copy link
Author

Thanks, #5 has resolved this issue.

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

Successfully merging a pull request may close this issue.

3 participants