Skip to content

fix: make dns enable/disable drop-in logic testable off-Linux (8 red tests on macOS) - #434

Open
nivokvo wants to merge 1 commit into
moshcoder:mainfrom
nivokvo:fix/dns-dropin-tests-platform-independent
Open

fix: make dns enable/disable drop-in logic testable off-Linux (8 red tests on macOS)#434
nivokvo wants to merge 1 commit into
moshcoder:mainfrom
nivokvo:fix/dns-dropin-tests-platform-independent

Conversation

@nivokvo

@nivokvo nivokvo commented Aug 21, 2026

Copy link
Copy Markdown

Fixes #433

dnsCommand() read the platform via detectPlatform() directly, so every platform === "linux" gate — preflight drop-in conflicts on enable, foreign/--remove-foreign detection and restore-point capture on disable — was dead code at test time on macOS/Windows. The tests inject everything else; the injected dropins were simply never consulted off-Linux.

Change

  • src/dns.mjs: platform becomes an injectable dep (platform: platformImpl = detectPlatform) — the same pattern the file already uses for dropins, applyWith, verify, and friends per its own comment about testability without a real machine.
  • test/dns-disable-restore.test.mjs, test/dns-enable-rollback.test.mjs: fixtures pin platform: () => "linux", matching the systemd behavior their assertions describe. No product behavior changes — default stays the real detected platform.

Result

Local suite on macOS: 2022 pass / 15 fail → 2030 pass / 7 fail. The remaining 7 are unrelated environment-bound failures (pty, proxy certificates, zsh job control).

dnsCommand() called detectPlatform() directly and gated every
drop-in-dependent branch on platform === 'linux'. On any other OS the
gates were dead: injected dropins were never consulted, foreign
detection returned nothing, captureRestorePoint skipped its files — so
eight enable/disable tests failed on macOS (and would on Windows) while
passing in CI on ubuntu.

Everything else in that decision tree is already injectable 'so the
decision logic is testable without a resolver, a root shell or a
machine whose DNS is a real thing to break' — platform now follows the
same rule. Tests pin platform: () => 'linux' in noSystem(), which is
the host shape their fixtures were built for. No product behavior
changed: the default remains the real detected platform.
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.

Bug: dns enable/disable drop-in logic is untestable off-Linux — 8 tests fail on macOS

1 participant