Files
Agent-System-Backend/internal/server/command_pairs_test.go
T
weichen f1302ed5b3 Enable canonical versioned Go module consumption
Why: Allow consumers to download an immutable module revision without nested source checkouts or local path replacements.

Evidence: SELF package tests and the prior canonical-path rejection are recorded in the Dev dependency-workspace task card; remote consumption is replayed against the committed candidate.

Impact: Change the module identity and its Go imports while preserving API behavior. Existing historical submodule revisions remain buildable.

Refs: Versioned dependencies U1/U3; feature/dependency-workspace
2026-10-13 15:47:16 +00:00

47 lines
1.2 KiB
Go

package server
import (
"encoding/json"
"os"
"path/filepath"
"testing"
agentcommand "git-ssh.u1680832.nyat.app/weichen/Agent-Command.git"
"git-ssh.u1680832.nyat.app/weichen/Agent-System-Backend.git/internal/cmdbus"
)
type pair struct {
ID string `json:"id"`
Button bool `json:"button"`
Chat bool `json:"chat"`
}
type nopAudit struct{}
func (nopAudit) AppendAudit(string, agentcommand.AuditEnvelope) error { return nil }
// 每个内置命令都必须在 command-pairs.json 里同时声明按钮入口与对话入口。
// 新命令漏登记则本测试失败,合入被挡住。
func TestBuiltinCommandsHaveDualEntryPairs(t *testing.T) {
raw, err := os.ReadFile(filepath.Join("testdata", "command-pairs.json"))
if err != nil {
t.Fatal(err)
}
var pairs []pair
if err := json.Unmarshal(raw, &pairs); err != nil {
t.Fatal(err)
}
byID := map[string]pair{}
for _, p := range pairs {
byID[p.ID] = p
}
s := &Server{Bus: cmdbus.New(nopAudit{}, nil, nil)}
s.WireBuiltinCommands()
for _, cmd := range s.Bus.List() {
p, ok := byID[cmd.Spec.ID]
if !ok || !p.Button || !p.Chat {
t.Errorf("command %s missing dual-entry pair (button and chat)", cmd.Spec.ID)
}
}
}