MCPcopy Create free account
hub / github.com/diillson/chatcli / TestHubResolveAppendReadFlow

Function TestHubResolveAppendReadFlow

server/handler_hub_test.go:36–62  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34}
35
36func TestHubResolveAppendReadFlow(t *testing.T) {
37 h := newHubHandler(t)
38 ctx := userCtx("alice", RoleUser)
39
40 res, err := h.ResolveActiveConversation(ctx, &pb.ResolveActiveConversationRequest{})
41 if err != nil {
42 t.Fatalf("ResolveActiveConversation: %v", err)
43 }
44 if res.ConvId == "" || res.Principal != "alice" {
45 t.Fatalf("unexpected resolve response: %+v", res)
46 }
47
48 _, err = h.AppendEvent(ctx, &pb.AppendEventRequest{
49 ConvId: res.ConvId, Channel: "local", Role: "user", Content: "hi from notebook",
50 })
51 if err != nil {
52 t.Fatalf("AppendEvent: %v", err)
53 }
54
55 read, err := h.ReadConversation(ctx, &pb.ReadConversationRequest{ConvId: res.ConvId})
56 if err != nil {
57 t.Fatalf("ReadConversation: %v", err)
58 }
59 if len(read.Events) != 1 || read.Events[0].Content != "hi from notebook" {
60 t.Fatalf("unexpected read: %+v", read.Events)
61 }
62}
63
64func TestHubCrossPrincipalIsolation(t *testing.T) {
65 h := newHubHandler(t)

Callers

nothing calls this directly

Calls 5

newHubHandlerFunction · 0.85
userCtxFunction · 0.85
AppendEventMethod · 0.65
ReadConversationMethod · 0.65

Tested by

no test coverage detected