Skip to content

test(core): split registry tests into unit and integration scopes#1029

Open
Tranquility2 wants to merge 3 commits into
mainfrom
mock_registry_tests
Open

test(core): split registry tests into unit and integration scopes#1029
Tranquility2 wants to merge 3 commits into
mainfrom
mock_registry_tests

Conversation

@Tranquility2
Copy link
Copy Markdown
Contributor

@Tranquility2 Tranquility2 commented Jun 2, 2026

I've wanted to clean this up for a while, core/tests/test_core_registry.py was an outlier.
It used DockerRegistryContainer (a sibling module) to test DockerClient'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 bits testcontainers actually owns: login wiring from docker_auth_config and create()'s pull-on-miss path.
    Runs offline, no skips, no dependency on the registry module.
    Mock setup lives in a small reusable registry_mocks.py helper, constrained with spec=docker.DockerClient so unknown SDK calls fail loudly.
  • modules/registry/tests/ gets one real round-trip test that proves auto-login via DOCKER_AUTH_CONFIG actually 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 (no insecure-registries config required).

Drive-by: empty auths ('{\"auths\": {}}') used to raise ValueError and crash DockerClient() 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.

Note for reviewers: please merge rather than squash.
The 3 commits are intentionally standalone (unit-test refactor, auth.py fix + mock tightening, integration test) and are easier to read / bisect kept separate.

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

codecov Bot commented Jun 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.94%. Comparing base (1fadb40) to head (340fef4).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant