TestLocalHubClientResolveAppendRead covers the on-disk client used by local hub mode: it resolves with the configured principal and round-trips events.
(t *testing.T)
| 19 | // TestLocalHubClientResolveAppendRead covers the on-disk client used by local |
| 20 | // hub mode: it resolves with the configured principal and round-trips events. |
| 21 | func 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 |
nothing calls this directly
no test coverage detected