mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-12-06 12:24:44 +00:00
The extra sentence appeared with the host path outside sandbox mode, where it is false. Add it only when SandboxRequired, pin that with the host test, and cover workerArtifactSpec in the sandbox test.
44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package agent
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/Autumn-27/artex/sandbox"
|
|
)
|
|
|
|
func TestArtifactSpecUsesContainerWorkdirInSandbox(t *testing.T) {
|
|
SetSandboxExecutor(&SandboxExecutor{Mode: sandbox.ModeRequired})
|
|
t.Cleanup(func() { SetSandboxExecutor(nil) })
|
|
got := artifactSpec("/app/data/tasks/t1/main")
|
|
if !strings.Contains(got, "/workspace/main") {
|
|
t.Fatalf("artifactSpec = %q, want the container work dir", got)
|
|
}
|
|
if strings.Contains(got, "/app/data/tasks") {
|
|
t.Fatalf("artifactSpec leaks the host path: %q", got)
|
|
}
|
|
}
|
|
|
|
func TestArtifactSpecKeepsHostPathOutsideSandbox(t *testing.T) {
|
|
SetSandboxExecutor(nil)
|
|
got := artifactSpec("/app/data/tasks/t1/main")
|
|
if !strings.Contains(got, "/app/data/tasks/t1/main") {
|
|
t.Fatalf("artifactSpec = %q, want the host work dir", got)
|
|
}
|
|
if strings.Contains(got, "container path") {
|
|
t.Fatalf("artifactSpec claims a container path outside sandbox mode: %q", got)
|
|
}
|
|
}
|
|
|
|
func TestWorkerArtifactSpecUsesContainerWorkdirInSandbox(t *testing.T) {
|
|
SetSandboxExecutor(&SandboxExecutor{Mode: sandbox.ModeRequired})
|
|
t.Cleanup(func() { SetSandboxExecutor(nil) })
|
|
got := workerArtifactSpec("/app/data/tasks/t1/i10")
|
|
if !strings.Contains(got, "/workspace/i10") {
|
|
t.Fatalf("workerArtifactSpec = %q, want the container work dir", got)
|
|
}
|
|
if strings.Contains(got, "/app/data/tasks") {
|
|
t.Fatalf("workerArtifactSpec leaks the host path: %q", got)
|
|
}
|
|
}
|