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

Introduce httptest for API mocking; update to testthat 3e #223

Merged
merged 17 commits into from
Apr 18, 2024

Conversation

nealrichardson
Copy link
Collaborator

@nealrichardson nealrichardson commented Apr 5, 2024

This PR adds https://enpiar.com/r/httptest/ for testing the API client with mock/recorded API responses. This allows contributors to run tests for the R code without having to run a local Connect server, which is not an option for most. I'd like to get some good overall coverage of the package's behaviors before doing any refactoring, just so we have some confidence that we aren't breaking things.

Before this PR, the line coverage of the non-integration tests was 15%. I've added some basic tests for Content, Permissions, and Users, pulling in the fixtures from posit-sdk-py. This gets coverage up to 24%. Followup PRs can extend this approach to get more coverage.

I avoided making changes in the package itself, though I did fix a bug in an error message builder, one broken API doc link, and I added Config/testthat/edition: 3 to the DESCRIPTION, both of which triggered some autoformatting.

I also removed the mockery dependency, as it was only being used in one test that could be rewritten to use a mock request.

@nealrichardson
Copy link
Collaborator Author

Integration test failures say the license has expired: https://github.com/rstudio/connectapi/actions/runs/8571214328/job/23490961358?pr=223#step:7:28

@colearendt @aronatkins can we fix this?

@aronatkins
Copy link
Contributor

@colearendt @aronatkins can we fix this?

I do not have sufficient rights. It'll have to be @colearendt.

@nealrichardson
Copy link
Collaborator Author

Integration tests are running now that this is rebased on main, but now they're failing, I'm guessing it has to do with testthat 3e. I'll fix.

@nealrichardson nealrichardson force-pushed the httptest branch 2 times, most recently from b691659 to 22ab78a Compare April 17, 2024 15:38
@nealrichardson nealrichardson changed the title Introduce httptest for API mocking Introduce httptest for API mocking; update to testthat 3e Apr 17, 2024
@nealrichardson nealrichardson merged commit 8d0a0d9 into main Apr 18, 2024
19 checks passed
@nealrichardson nealrichardson deleted the httptest branch April 18, 2024 21:29
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 this pull request may close these issues.

2 participants