mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-05 02:30:26 +08:00
Add multi-platform testing (Ubuntu, Windows, macOS) to CI workflow. Add unit tests for cross-platform path handling, stdin mode triggers, and codex command construction to address issue #137. Generated with SWE-Agent.ai Co-Authored-By: SWE-Agent.ai <noreply@swe-agent.ai>
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package backend
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
config "codeagent-wrapper/internal/config"
|
|
)
|
|
|
|
func TestBuildCodexArgs_Workdir_OSPaths(t *testing.T) {
|
|
t.Setenv("CODEX_BYPASS_SANDBOX", "false")
|
|
|
|
tests := []struct {
|
|
name string
|
|
workdir string
|
|
}{
|
|
{name: "windows drive forward slashes", workdir: "D:/repo/path"},
|
|
{name: "windows drive backslashes", workdir: `C:\repo\path`},
|
|
{name: "windows UNC", workdir: `\\server\share\repo`},
|
|
{name: "unix absolute", workdir: "/home/user/repo"},
|
|
{name: "relative", workdir: "./relative/repo"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
cfg := &config.Config{Mode: "new", WorkDir: tt.workdir}
|
|
got := BuildCodexArgs(cfg, "task")
|
|
want := []string{"e", "--skip-git-repo-check", "-C", tt.workdir, "--json", "task"}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("BuildCodexArgs() = %v, want %v", got, want)
|
|
}
|
|
})
|
|
}
|
|
|
|
t.Run("new mode stdin target uses dash", func(t *testing.T) {
|
|
cfg := &config.Config{Mode: "new", WorkDir: `C:\repo\path`}
|
|
got := BuildCodexArgs(cfg, "-")
|
|
want := []string{"e", "--skip-git-repo-check", "-C", `C:\repo\path`, "--json", "-"}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("BuildCodexArgs() = %v, want %v", got, want)
|
|
}
|
|
})
|
|
}
|
|
|
|
func TestBuildCodexArgs_ResumeMode_OmitsWorkdir(t *testing.T) {
|
|
t.Setenv("CODEX_BYPASS_SANDBOX", "false")
|
|
|
|
cfg := &config.Config{Mode: "resume", SessionID: "sid-123", WorkDir: `C:\repo\path`}
|
|
got := BuildCodexArgs(cfg, "-")
|
|
want := []string{"e", "--skip-git-repo-check", "--json", "resume", "sid-123", "-"}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("BuildCodexArgs() = %v, want %v", got, want)
|
|
}
|
|
}
|