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
Open
Conversation
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.
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.
Fixes #433
dnsCommand()read the platform viadetectPlatform()directly, so everyplatform === "linux"gate — preflight drop-in conflicts on enable, foreign/--remove-foreigndetection and restore-point capture on disable — was dead code at test time on macOS/Windows. The tests inject everything else; the injecteddropinswere simply never consulted off-Linux.Change
src/dns.mjs:platformbecomes an injectable dep (platform: platformImpl = detectPlatform) — the same pattern the file already uses fordropins,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 pinplatform: () => "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).