Files
tutti/services/tuttid/service/agentextension/install_command_windows_test.go
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

43 lines
1.3 KiB
Go

//go:build windows
package agentextension
import (
"context"
"os"
"path/filepath"
"reflect"
"strings"
"testing"
)
func TestAgentExtensionCommandUsesCmdForNPMShim(t *testing.T) {
t.Setenv("ComSpec", `C:\Windows\System32\cmd.exe`)
command := newAgentExtensionCommand(
context.Background(),
`C:\Program Files\nodejs\npm.cmd`,
"install", "--prefix", `C:\runtime root`, "@example/probe@1.0.0",
)
want := []string{
`C:\Windows\System32\cmd.exe`, "/D", "/S", "/C", "call",
`C:\Program Files\nodejs\npm.cmd`, "install", "--prefix", `C:\runtime root`, "@example/probe@1.0.0",
}
if command.Path != want[0] || !reflect.DeepEqual(command.Args, want) {
t.Fatalf("Windows npm command = path %q args %#v, want %#v", command.Path, command.Args, want)
}
}
func TestAgentExtensionCommandExecutesBatchLauncher(t *testing.T) {
launcher := filepath.Join(t.TempDir(), "generic-agent.cmd")
if err := os.WriteFile(launcher, []byte("@echo off\r\necho 1.2.3\r\n"), 0o600); err != nil {
t.Fatal(err)
}
output, err := newAgentExtensionCommand(context.Background(), launcher, "--version").CombinedOutput()
if err != nil {
t.Fatalf("execute Windows batch launcher: %v; output=%q", err, output)
}
if strings.TrimSpace(string(output)) != "1.2.3" {
t.Fatalf("Windows batch launcher output = %q, want 1.2.3", output)
}
}