169e6c0f00
- Adds a --clone-into option to the container-instance command to clone repository contents into a specified path during container setup. - Fixes the devcontainer-instance sandbox strategy to ensure proper isolation, correct mount permissions, and deterministic behavior across environments. - Updates related validation and error handling to reflect the new option and sandbox changes. ISSUES CLOSED: #7555
85 lines
4.1 KiB
Gherkin
85 lines
4.1 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
|