MCPcopy Create free account
hub / github.com/openclaw/gogcli / TestProcessorHandleHistory

Function TestProcessorHandleHistory

internal/gmailwatch/processor_test.go:56–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

54}
55
56func TestProcessorHandleHistory(t *testing.T) {
57 t.Parallel()
58
59 now := time.Unix(100, 0)
60 repository := NewMemory(State{Account: "a@example.com", HistoryID: "100"}, Options{Now: func() time.Time { return now }})
61 source := &processorSource{
62 history: HistoryPage{
63 HistoryID: "201",
64 Records: []HistoryRecord{{
65 Added: []string{"m1"},
66 Deleted: []string{"m2"},
67 }},
68 },
69 messageBatches: []MessageBatch{{Messages: []Message{{ID: "m1"}}}},
70 }
71 processor := newTestProcessor(repository, source, now)
72
73 payload, err := processor.Handle(context.Background(), Notification{HistoryID: "200", MessageID: "push-1"})
74 if err != nil {
75 t.Fatalf("Handle: %v", err)
76 }
77
78 if payload.HistoryID != "201" || len(payload.Messages) != 1 || payload.Messages[0].ID != "m1" {
79 t.Fatalf("payload = %#v", payload)
80 }
81
82 if want := []string{"m2"}; !reflect.DeepEqual(payload.DeletedMessageIDs, want) {
83 t.Fatalf("deleted IDs = %v, want %v", payload.DeletedMessageIDs, want)
84 }
85
86 state := repository.Get()
87 if state.HistoryID != "201" || state.LastPushMessageID != "push-1" {
88 t.Fatalf("state = %#v", state)
89 }
90}
91
92func TestProcessorSuppressesDuplicateAndStaleNotifications(t *testing.T) {
93 t.Parallel()

Callers

nothing calls this directly

Calls 4

NewMemoryFunction · 0.85
newTestProcessorFunction · 0.85
HandleMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected