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
57 lines
1.9 KiB
Go
57 lines
1.9 KiB
Go
package cardsvc
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git-ssh.u1680832.nyat.app/weichen/Agent-System-Backend.git/internal/store"
|
|
core "git-ssh.u1680832.nyat.app/weichen/Agent-System-Core.git"
|
|
)
|
|
|
|
// EXT-12 最小开关(红测):MirrorConvCards=false 时会话卡不镜像进项目公共流
|
|
// (不发布即不持久,重放天然不含会话卡);项目级卡不受影响;缺省 true 保持现状。
|
|
func TestConvCardMirrorSwitch(t *testing.T) {
|
|
newSvc := func(mirror bool) (*Service, *[]string) {
|
|
chans := []string{}
|
|
emit := func(convID, runID string, typ core.StreamEventType, payload any) error {
|
|
chans = append(chans, convID)
|
|
return nil
|
|
}
|
|
st, err := store.OpenSQLite(t.TempDir() + "/cards.db")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Cleanup(func() { st.Close() })
|
|
svc := New(st, emit)
|
|
svc.MirrorConvCards = mirror
|
|
return svc, &chans
|
|
}
|
|
card := core.ActivityCard{ConversationID: "c-priv", ProjectID: "p-1", Kind: core.CardKindProgress, Title: "私有过程卡"}
|
|
|
|
// 开(缺省现状):会话流 + 项目流双发。
|
|
svc, chans := newSvc(true)
|
|
if _, err := svc.Create("alice", card, ""); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(*chans) != 2 {
|
|
t.Fatalf("mirror on: emitted %v, want 会话流+项目流", *chans)
|
|
}
|
|
|
|
// 关:只进本人会话流,项目公共流零事件。
|
|
svc2, chans2 := newSvc(false)
|
|
if _, err := svc2.Create("alice", card, ""); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(*chans2) != 1 || (*chans2)[0] != "c-priv" {
|
|
t.Fatalf("mirror off: emitted %v, want 仅会话流 c-priv(项目流不得发布)", *chans2)
|
|
}
|
|
|
|
// 项目级卡(无会话归属)不受开关影响。
|
|
pc := core.ActivityCard{ProjectID: "p-1", Kind: core.CardKindProgress, Title: "项目级卡"}
|
|
if _, err := svc2.Create("alice", pc, ""); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(*chans2) != 2 || (*chans2)[1] != string(core.ProjectChannelKey("p-1")) {
|
|
t.Fatalf("project-level card must still publish: %v", *chans2)
|
|
}
|
|
}
|