Skip to content

[repo-health] Medium: docker module has no unit tests — critical container logic is untested #16

Description

@Liohtml

Summary

The docker module (src/docker/index.ts) owns all image build, container run/exec, and host-mount logic, but there is no corresponding tests/docker.test.ts. Every other module (cli/config, observer, parser, session) has a test file, leaving the most operationally critical code completely uncovered.

Category

Tests

Severity

Medium

Details

tests/ contains:

  • config.test.ts — covers CLI config resolution
  • observer.test.ts — covers observer output parsing
  • parser.test.ts — covers argument parser
  • session.test.ts — covers tmux entry-script generation

Missing: docker.test.ts

The docker module (src/docker/index.ts) exports a DockerModule object with 8 methods: available, imageExists, containerExists, containerRunning, removeContainer, ensureHostMounts, runContainer, execAttach. None of these are covered by tests. The ensureHostMounts function in particular writes to the filesystem and has a subtle edge case (a directory where a file is expected) that is documented in code comments but not exercised.

Suggested Fix

Add tests/docker.test.ts using the Node built-in test runner (matching the project's existing pattern). The DockerModule interface pattern in src/types.ts allows injecting a mock implementation, so tests can verify orchestration logic without requiring a live Docker daemon:

// stub the docker binary with a mock implementation
const mockDocker: DockerModule = { available: async () => true, ... };

At minimum, cover: ensureHostMounts with a real tmpdir, containerExists/containerRunning parsing logic, and the runContainer argument assembly.

Effort Estimate

1 hour+


Automated finding by repo-health-agent v1.0

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions