(t *testing.T)
| 143 | } |
| 144 | |
| 145 | func 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 | |
| 168 | func TestHubSyncBindAndList(t *testing.T) { |
| 169 | fc := newFakeHubClient() |
nothing calls this directly
no test coverage detected