Why: identity ensure/verify went through the normal store open, which creates a database and runs migrations. A deploy gate that calls the candidate before stopping the old service could migrate production ahead of the switch, and a missing database was turned into an empty one. Evidence: go test ./pkg/identity/ ./internal/store/ ./cmd/agent-system/ -run 'TestCapabilities|TestEnsure|TestVerify|TestDSN|TestUsage|TestSystemIdentity|TestOpenIdentity|TestUnknownSubcommand' passed in this worktree. Impact: identity CLI refuses a missing file or a missing agent_system_identity table, does not migrate, reads DSN from the environment or a 0600 file, and version --json plus identity capabilities emit one capability document. Unknown top-level commands exit 2. Refs: recovery plan r3.1 D1; Dev feature/svc-d1-identity-flow Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
724 B
Go
29 lines
724 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestUnknownSubcommandExits(t *testing.T) {
|
|
if os.Getenv("DISPATCH_CHILD") == "1" {
|
|
os.Args = []string{"agent-system", "not-a-command"}
|
|
main()
|
|
return
|
|
}
|
|
cmd := exec.Command(os.Args[0], "-test.run=TestUnknownSubcommandExits")
|
|
cmd.Env = append(os.Environ(), "DISPATCH_CHILD=1")
|
|
out, err := cmd.CombinedOutput()
|
|
if err == nil {
|
|
t.Fatalf("未知子命令应非零退出:%s", out)
|
|
}
|
|
if !strings.Contains(string(out), "未知子命令") {
|
|
t.Fatalf("输出:%s", out)
|
|
}
|
|
if strings.Contains(string(out), "agent-system starting") || strings.Contains(string(out), "serving") {
|
|
t.Fatalf("未知子命令落入了服务路径:%s", out)
|
|
}
|
|
}
|