Skip to content

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

Description

@nivokvo

Bug

dnsCommand() calls detectPlatform() directly and gates the drop-in-dependent branches on platform === "linux" && linuxBackend === "systemd-resolved":

  • enable: checkDropins → preflight conflict/duplicate scan
  • disable: routed/foreign detection, --remove-foreign, restore-point capture via captureRestorePoint

On macOS (and Windows) those gates are dead code at test time. The tests inject dropins, but the platform is read from the real machine — so the injected fixtures are never consulted, foreign detection always returns empty, and restore points come back missing files.

8 tests fail on a Mac checkout while CI (ubuntu) stays green:

✖ with no manifest, a foreign drop-in is named and NOT removed...
✖ --remove-foreign removes it, and only then
✖ no manifest and nothing routed is a clean no-op...
✖ --dry-run for disable names every file and writes nothing
✖ a conflicting drop-in stops the run before anything is written
✖ enable records what the machine looked like before it changes it
✖ --dry-run writes nothing, restarts nothing...
✖ --dry-run still reports a preflight that would refuse

The deps comment in dnsCommand already states the principle: injected so the decision logic is testable without a resolver, a root shell or a machine whose DNS is a real thing to break. Platform is the one input left hardcoded.

Fix (PR incoming)

Make platform an injectable dep defaulting to detectPlatform — same pattern as every other dependency — and pin platform: () => "linux" in the two fixtures whose assertions describe systemd behavior. No product behavior changes; on master the suite went 2022/15 → 2030/7 locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions