(t *testing.T)
| 54 | } |
| 55 | |
| 56 | func 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 | |
| 92 | func TestProcessorSuppressesDuplicateAndStaleNotifications(t *testing.T) { |
| 93 | t.Parallel() |
nothing calls this directly
no test coverage detected