Skip to content

[Refactoring] Split src/services/agent-volumes-mounts.test.ts (862 lines) by volume-mount feature area #5490

Description

@github-actions

Refactoring Opportunity

Summary

  • File: src/services/agent-volumes-mounts.test.ts
  • Current size: 862 lines
  • Responsibilities identified: 6 distinct volume-mount feature areas in one flat describe block

Evidence

The file has one top-level describe('agent service', ...) block (line 43) with 35+ flat it() test cases and zero sub-describe grouping. Six distinct functional areas are intermixed across 820 lines:

  1. Basic mounts (lines 44–155): default required volumes, custom volume mounts, path normalization, trailing-slash handling.
  2. ARC/DinD staging (lines 159–303): ARC runner binary staging, PATH candidate selection, path escaping guard, etc/passwd/etc/group non-prefixing.
  3. Docker socket / DinD exposure (lines 330–503): api-proxy health-check mount, enableDind flag, DOCKER_HOST env forwarding, invalid-socket fallback.
  4. Toolchain mounts (lines 504–624): Rust/cargo, npm, Gemini API key dir, container.runnerToolCachePath, RUNNER_TOOL_CACHE, symlink exclusion.
  5. Chroot host-access mounts (lines 625–760): enableHostAccess, custom chroot-hosts file, host.docker.internal injection, sessionStateDir.
  6. DNS pre-resolution in mounts (lines 761–862): domain-to-IP pre-resolution, failed-resolution skip, duplicate deduplication.

There are no describe() sub-groups at all. Finding the test for a specific feature (e.g., "does the Gemini dir get mounted?") requires scanning the entire 862-line file.

Proposed Split

Split into focused test files, each importing shared fixtures from service-test-setup.test-utils:

  • agent-volumes-basic.test.ts — default and custom mounts, path prefixing (~155 lines)
  • agent-volumes-arc-dind-staging.test.ts — ARC staging, binary path resolution (~150 lines)
  • agent-volumes-dind-socket.test.ts — Docker socket exposure, enableDind, DOCKER_HOST (~175 lines)
  • agent-volumes-toolchain.test.ts — toolchain dirs, tool-cache paths, symlink exclusion (~130 lines)
  • agent-volumes-chroot-hosts.test.ts — chroot host-access, custom hosts injection (~140 lines)
  • agent-volumes-dns-preresolution.test.ts — DNS pre-resolution in bind mounts (~110 lines)

This matches the splitting pattern used for docker-manager-lifecycle.test.ts, docker-manager-cleanup.test.ts, and docker-manager-utils.test.ts.

Effort Estimate

Low

Benefits

  • Test failures immediately name the affected feature area (DinD, toolchain, DNS, etc.)
  • 150-line files are scannable in seconds vs. an 862-line monolith
  • Individual feature-area tests run faster in isolation during development
  • Consistent with existing split-test conventions in this codebase

Detected by Refactoring Scanner workflow. Run date: 2026-06-24

Generated by Refactoring Opportunity Scanner · 140.6 AIC · ⊞ 6.9K ·

  • expires on Aug 23, 2026, 3:58 PM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions