Skip to content

test(ACP): Add missing unit coverage for restore command flows #23402

@samar-703

Description

@samar-703

Summary

ACP restore commands currently lack direct unit tests for key success and failure paths in:

  • packages/cli/src/acp/commands/restore.ts

This creates risk for regressions in checkpoint restore/list behavior and user-facing error messages.

Problem

RestoreCommand and ListCheckpointsCommand include multiple branches that are easy to break without explicit
tests, including:

  • checkpointing disabled handling
  • missing checkpoint file handling (ENOENT)
  • invalid/corrupt checkpoint data handling
  • restore stream result formatting
  • fallback/unexpected error handling
  • checkpoint listing and formatting behavior

Proposed Solution

Add a dedicated test suite:

  • packages/cli/src/acp/commands/restore.test.ts

Cover these scenarios:

RestoreCommand

  • Delegates to list behavior when invoked without args
  • Returns checkpointing-disabled message
  • Returns file-not-found message for missing checkpoint
  • Returns invalid/corrupt checkpoint message when schema parse fails
  • Formats streamed restore results (message, load_history, fallback object)
  • Returns generic unexpected error message for non-ENOENT failures

ListCheckpointsCommand

  • Returns checkpointing-disabled message
  • Returns No checkpoints found. when no .json checkpoints exist
  • Formats checkpoint summary output from checkpoint metadata
  • Returns generic unexpected error message on failures

Acceptance Criteria

  • New restore ACP test file exists and runs successfully.
  • All branches above are explicitly asserted.
  • Command output strings remain stable and verified by tests.
  • No production/runtime code changes are required for this issue.

Validation

Run:

  • npm run build --workspace @google/gemini-cli-core
  • npm run test --workspace @google/gemini-cli -- src/acp/commands/restore.test.ts

Expected: restore ACP tests pass.

Related PR

Related to #23400

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/coreIssues related to User Interface, OS Support, Core Functionalitystatus/need-triageIssues that need to be triaged by the triage automation.

    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