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

Function TestLocalHubClientResolveAppendRead

cli/hub_local_test.go:21–42  ·  view source on GitHub ↗

TestLocalHubClientResolveAppendRead covers the on-disk client used by local hub mode: it resolves with the configured principal and round-trips events.

(t *testing.T)

Source from the content-addressed store, hash-verified

19// TestLocalHubClientResolveAppendRead covers the on-disk client used by local
20// hub mode: it resolves with the configured principal and round-trips events.
21func TestLocalHubClientResolveAppendRead(t *testing.T) {
22 store, err := hub.OpenSQLiteStore(context.Background(), filepath.Join(t.TempDir(), "hub.db"), nil)
23 if err != nil {
24 t.Fatalf("open: %v", err)
25 }
26 t.Cleanup(func() { _ = store.Close() })
27
28 c := newLocalHubClient(store, "edilson")
29 ctx := context.Background()
30
31 conv, principal, err := c.ResolveActiveConversation(ctx, "")
32 if err != nil || conv == "" || principal != "edilson" {
33 t.Fatalf("resolve = %q,%q,%v", conv, principal, err)
34 }
35 if _, err := c.AppendEvent(ctx, models.ConversationEvent{ConvID: conv, Channel: hubChannelLocal, Role: models.ConvRoleUser, Content: "hi"}); err != nil {
36 t.Fatalf("append: %v", err)
37 }
38 got, err := c.ReadConversation(ctx, conv, 0, 0)
39 if err != nil || len(got) != 1 || got[0].Content != "hi" || got[0].Principal != "edilson" {
40 t.Fatalf("read = %+v, %v", got, err)
41 }
42}
43
44// TestLocalHubPollingPicksUpExternalAppend proves the realtime path: a turn
45// written by another process (a second handle on the same db, standing in for

Callers

nothing calls this directly

Calls 7

OpenSQLiteStoreFunction · 0.92
newLocalHubClientFunction · 0.85
CloseMethod · 0.65
AppendEventMethod · 0.65
ReadConversationMethod · 0.65
CleanupMethod · 0.45

Tested by

no test coverage detected