chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,54 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"academy/cli/internal/cmdutil"
|
||||
)
|
||||
|
||||
// TestAgentInvoke_NowReturnsUnknownSubcommand verifies the deleted v0.6
|
||||
// command emits a typed envelope rather than cobra's free-form exit-2 prose.
|
||||
func TestAgentInvoke_NowReturnsUnknownSubcommand(t *testing.T) {
|
||||
root := NewRootCmd(cmdutil.New())
|
||||
root.SetArgs([]string{"agent", "invoke", "ag_x", "q"})
|
||||
root.SetOut(&bytes.Buffer{})
|
||||
root.SetErr(&bytes.Buffer{})
|
||||
err := root.Execute()
|
||||
ce := cmdutil.AsError(err)
|
||||
if ce == nil || ce.Code != cmdutil.CodeInputUnknownSubcommand {
|
||||
t.Errorf("expected CodeInputUnknownSubcommand, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnknownSubcommand_EmitsTypedEnvelope(t *testing.T) {
|
||||
t.Cleanup(func() { cmdutil.SetFormatMode("") })
|
||||
|
||||
root := NewRootCmd(cmdutil.New())
|
||||
var stderr bytes.Buffer
|
||||
root.SetErr(&stderr)
|
||||
root.SetArgs([]string{"fooo"})
|
||||
|
||||
err := root.Execute()
|
||||
if err == nil {
|
||||
t.Fatal("expected unknown-subcommand error, got nil")
|
||||
}
|
||||
|
||||
// Force JSON mode for PrintError regardless of how PersistentPreRunE
|
||||
// resolved it during the test invocation (no TTY in test buffer).
|
||||
cmdutil.SetFormatMode("json")
|
||||
mapped := MapCobraError(err)
|
||||
cmdutil.PrintError(&stderr, mapped)
|
||||
|
||||
got := stderr.String()
|
||||
if !strings.Contains(got, `"type":"input.unknown_subcommand"`) {
|
||||
t.Errorf("expected typed code; got %q", got)
|
||||
}
|
||||
if !strings.Contains(got, `"available":[`) {
|
||||
t.Errorf("expected detail.available[]; got %q", got)
|
||||
}
|
||||
if !strings.Contains(got, `"retry_argv":["academy","--help"]`) {
|
||||
t.Errorf("expected retry_argv; got %q", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user