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

Function TestHubSyncPullSkipsLocalReturnsOthers

cli/hub_sync_test.go:145–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

143}
144
145func TestHubSyncPullSkipsLocalReturnsOthers(t *testing.T) {
146 fc := newFakeHubClient()
147 hs := newHubSync(fc, zap.NewNop())
148 if err := hs.startFresh(context.Background()); err != nil {
149 t.Fatalf("startFresh: %v", err)
150 }
151
152 // A local echo (skip) and a telegram turn (deliver) land on the conversation.
153 fc.seed(
154 models.ConversationEvent{Channel: hubChannelLocal, Role: models.ConvRoleUser, Content: "my own"},
155 models.ConversationEvent{Channel: "telegram", Role: models.ConvRoleUser, Content: "from phone"},
156 )
157
158 msgs := hs.pull(context.Background())
159 if len(msgs) != 1 || msgs[0].Content != "from phone" {
160 t.Fatalf("pull should return only the telegram turn, got %+v", msgs)
161 }
162 // A second pull returns nothing new (watermark advanced past both).
163 if more := hs.pull(context.Background()); len(more) != 0 {
164 t.Fatalf("second pull should be empty, got %+v", more)
165 }
166}
167
168func TestHubSyncBindAndList(t *testing.T) {
169 fc := newFakeHubClient()

Callers

nothing calls this directly

Calls 5

newFakeHubClientFunction · 0.85
newHubSyncFunction · 0.85
startFreshMethod · 0.80
seedMethod · 0.80
pullMethod · 0.80

Tested by

no test coverage detected