Enable offline cassette replay for VCR-backed tests#161
Merged
aaronwolen merged 8 commits intomasterfrom Feb 21, 2026
Merged
Conversation
Rename skip_on_production_server() to skip_if_not_test_server() for tests that depend on pre-existing assets on test.osf.io (test-osf_ls), and switch to skip_if_no_pat() for tests that require authentication (test-osf_tbl).
Add skip_if_not_test_server() for tests that depend on pre-existing assets on test.osf.io. Apply it to test-downloading.R (alongside skip_if_no_pat) and the test-osf_tbl "can't combine" test that uses a hardcoded test server GUID. Add a README documenting the three testing modes (offline with cassettes, live test server, live production server) and the skip helpers.
Wrap API calls in vcr::use_cassette() so these tests replay recorded responses instead of requiring a live connection to test.osf.io. This brings them in line with the rest of the test suite.
Remove `if (has_pat())` guards from setup blocks and `skip_if_no_pat()` from individual tests so VCR cassettes replay without credentials. Teardown blocks that conditionally clean up live resources are kept unchanged. Also remove the unnecessary skip from the pure `id_type()` test in test-identifiers.R. Offline results improve from ~30 pass / ~74 skip to 150 pass / 9 skip, with all remaining skips in test-downloading.R (which requires live file access).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
skip_if_no_pat()from all VCR-backed tests so they can run offline using recorded cassettesif (has_pat())guards and intovcr::use_cassette()blocks at file-level, enabling cassette replay without credentialsosf_lsandosf_tblso these test files no longer require a live serverskip_on_production_server()toskip_if_not_test_server()for clarity and add it alongsideskip_if_no_pat()in downloading tests, which are the only tests that still require live server accesscontext()calls, replacing them with section comment headerstests/testthat/README.mddocumenting the three testing modes (offline, test server, production server)NOTE: Only
test-downloading.Rrequires bothOSF_PATandOSF_SERVER=test, since downloads depend on pre-existing assets on test.osf.io and can't be meaningfully recorded as cassettes.