Files
Agent-System-Backend/internal/cmdbus/pending_store_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

34 lines
984 B
Go

package cmdbus
import (
"context"
"path/filepath"
"testing"
agentcommand "git-ssh.u1680832.nyat.app/weichen/Agent-Command.git"
"git-ssh.u1680832.nyat.app/weichen/Agent-System-Backend.git/internal/store"
)
func TestPendingConfirmRestoredAfterRestart(t *testing.T) {
st, err := store.OpenSQLite(filepath.Join(t.TempDir(), "c.db"))
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { st.Close() })
cards := &memCards{}
b := newTestBus(&memAudit{}, cards)
b.SetPendingStore(st)
resp := b.Dispatch(context.Background(), Request{
ID: "demo.risky", Params: map[string]any{"target": "prod"}, Entrance: "button", ConversationID: "cnv_1", Owner: "acme",
})
if resp.Card == nil {
t.Fatal("expected confirm card")
}
// 模拟重启:丢掉进程内 map,只留存储。
b.pending = map[string]pending{}
again := b.Confirm("acme", resp.Card.ID, "confirm")
if again.Receipt.State != agentcommand.StateCommitted {
t.Fatalf("restored confirm: %+v", again.Receipt)
}
}