Files
cleveragents-core/features/container_clone_into.feature
T
HAL9000 24026d26ea fix(resource): wire --clone-into into DevcontainerHandler.resolve() runtime path
The --clone-into CLI argument was registered and the helper
clone_repo_into_container() was implemented, but DevcontainerHandler.resolve()
never read the clone_into property or called the helper. This meant that
agents resource add container-instance --clone-into <url> silently ignored
the flag at runtime (acceptance criterion #2 from issue #7555 was unmet).

Wire the clone step into DevcontainerHandler.resolve(): after
activate_container() returns and the lifecycle tracker has a container_id,
validate the URL and call clone_repo_into_container(). Also add an
end-to-end BDD scenario that exercises the full handler to clone path via
mocks.

ISSUES CLOSED: #7555
2026-06-02 20:37:35 -04:00

93 lines
4.6 KiB
Gherkin

@clone-into
Feature: container-instance --clone-into argument
As a CleverAgents user
I want to clone a git repository into a running container
So that I can work with the repository inside the container environment
# URL validation
Scenario Outline: validate_clone_into_url accepts valid git URLs
When I validate clone-into URL "<url>"
Then the clone-into URL should be valid
Examples:
| url |
| https://github.com/org/repo.git |
| http://internal.example.com/repo.git |
| git@github.com:org/repo.git |
| ssh://git@bitbucket.org/org/repo.git |
| git://github.com/org/repo.git |
| /local/path/to/repo |
| ./relative/repo |
Scenario Outline: validate_clone_into_url rejects invalid URLs
When I validate clone-into URL "<url>"
Then the clone-into URL should be invalid
Examples:
| url |
| not-a-url |
| ftp://example.com |
# ── clone_repo_into_container argument validation ──────────
Scenario: clone_repo_into_container rejects empty container_id
When I call clone_repo_into_container with empty container_id
Then it should raise ValueError mentioning "container_id"
Scenario: clone_repo_into_container rejects empty repo_url
When I call clone_repo_into_container with empty repo_url
Then it should raise ValueError mentioning "repo_url"
# ── Successful clone ────────────────────────────────────────
Scenario: clone_repo_into_container succeeds when docker exec returns 0
Given a mock docker exec that succeeds for clone
When I clone "https://github.com/org/repo.git" into container "abc123def456"
Then the clone should succeed
And the clone target should be "/workspace"
Scenario: clone_repo_into_container uses custom target directory
Given a mock docker exec that succeeds for clone
When I clone repo "https://github.com/org/repo.git" into container "abc123def456" with target "/custom/dir"
Then the clone should succeed
And the clone target should be "/custom/dir"
# ── Failure handling ────────────────────────────────────────
Scenario: clone_repo_into_container raises CloneIntoError when docker exec fails
Given a mock docker exec that fails for clone with stderr "fatal: repository not found"
When I clone "https://github.com/org/missing.git" into container "abc123def456"
Then the clone should raise CloneIntoError
And the CloneIntoError should mention "repository not found"
# ── CloneIntoError attributes ──────────────────────────────
Scenario: CloneIntoError stores repo_url, container_id, and stderr
Given a CloneIntoError with repo "https://example.com/repo.git" container "ctr-001" stderr "auth failed"
Then the CloneIntoError repo_url should be "https://example.com/repo.git"
And the CloneIntoError container_id should be "ctr-001"
And the CloneIntoError stderr should be "auth failed"
# ── container-instance resource type has --clone-into arg ──
Scenario: container-instance resource type has clone-into CLI argument
When I look up the "container-instance" resource type spec
Then the spec should have a CLI argument named "clone-into"
And the clone-into argument should be of type "string"
And the clone-into argument should not be required
# ── validate_clone_into_url edge cases ─────────────────────
Scenario: validate_clone_into_url rejects whitespace-only string
When I validate clone-into URL with whitespace only
Then the clone-into URL should be invalid
# -- End-to-end handler wiring --
Scenario: DevcontainerHandler.resolve() calls clone_repo_into_container when clone_into property is set
Given a devcontainer-instance resource with clone_into "https://github.com/org/repo.git" and tracker container_id "abc123def456"
And clone_repo_into_container is mocked to succeed
When DevcontainerHandler.resolve() is called for the resource
Then clone_repo_into_container should have been called with container_id "abc123def456" and url "https://github.com/org/repo.git"