test(core): split registry tests into unit and integration scopes#1029
Open
Tranquility2 wants to merge 3 commits into
Open
test(core): split registry tests into unit and integration scopes#1029Tranquility2 wants to merge 3 commits into
Tranquility2 wants to merge 3 commits into
Conversation
Replace integration tests that spun up a real registry:2 container with unit tests that mock the Docker SDK (registry_mocks.py). Drops the macOS / SSH-host skips and runs offline. Also adds a missing edge-case test for empty auths in parse_docker_auth_config.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1029 +/- ##
==========================================
- Coverage 83.06% 82.94% -0.12%
==========================================
Files 16 16
Lines 1730 1730
Branches 190 190
==========================================
- Hits 1437 1435 -2
- Misses 236 239 +3
+ Partials 57 56 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
I've wanted to clean this up for a while,
core/tests/test_core_registry.pywas an outlier.It used
DockerRegistryContainer(a sibling module) to testDockerClient's auth-config wiring, mixing the library under test with its own test setup.It also carried macOS / SSH-host skip markers because of the insecure HTTP registry it stood up.
This PR splits the coverage along the right seams:
core/tests/gets fast, fully-mocked unit tests for the bitstestcontainersactually owns: login wiring fromdocker_auth_configandcreate()'s pull-on-miss path.Runs offline, no skips, no dependency on the registry module.
Mock setup lives in a small reusable
registry_mocks.pyhelper, constrained withspec=docker.DockerClientso unknown SDK calls fail loudly.modules/registry/tests/gets one real round-trip test that proves auto-login viaDOCKER_AUTH_CONFIGactually works, by seeding the private registry and then pulling without explicit credentials.Addresses the registry over
127.0.0.1:<port>so the daemon's loopback insecure-registry default kicks in, which means it also works against remote/SSH daemons (noinsecure-registriesconfig required).Drive-by: empty
auths('{\"auths\": {}}') used to raiseValueErrorand crashDockerClient()init.It now returns
[]("no credentials configured"), which is what users probably expect.Hopefully a small step toward making this part of the codebase easier to evolve.