Commit 94878ec5b8
Verified · cmc
Layout: unified · split
docs/plans/2026-09-20-ios-push-notifications.md +9 −5
| @@ -105,8 +105,7 @@ func TestPushDevices(t *testing.T) { | |||
| 105 | s := testStore(t) | 105 | s := testStore(t) |
| 106 | uid := testUser(t, s, "alice") | 106 | uid := testUser(t, s, "alice") |
| 107 | 107 | ||
| 108 | id, err := s.AddPushDevice(uid, "tok-a", "iphone") | 108 | if _, err := s.AddPushDevice(uid, "tok-a", "iphone"); err != nil { |
| 109 | if err != nil { | ||
| 110 | t.Fatalf("AddPushDevice: %v", err) | 109 | t.Fatalf("AddPushDevice: %v", err) |
| 111 | } | 110 | } |
| 112 | devices, err := s.PushDevices(uid) | 111 | devices, err := s.PushDevices(uid) |
| @@ -141,7 +140,6 @@ func TestPushDevices(t *testing.T) { | |||
| 141 | if d, _ := s.PushDevices(bob); len(d) != 0 { | 140 | if d, _ := s.PushDevices(bob); len(d) != 0 { |
| 142 | t.Fatalf("device survived removal: %+v", d) | 141 | t.Fatalf("device survived removal: %+v", d) |
| 143 | } | 142 | } |
| 144 | _ = id | ||
| 145 | } | 143 | } |
| 146 | 144 | ||
| 147 | func TestPushEnabledDefaultsOn(t *testing.T) { | 145 | func TestPushEnabledDefaultsOn(t *testing.T) { |
| @@ -806,7 +804,7 @@ Ref #89" | |||
| 806 | - Test: `internal/push/token_test.go` | 804 | - Test: `internal/push/token_test.go` |
| 807 | 805 | ||
| 808 | **Interfaces:** | 806 | **Interfaces:** |
| 809 | - Consumes: `config.Push`, `config.LoadAPNSKey` from Task 3. | 807 | - Consumes: nothing. `token.go` takes a parsed key and two strings; it imports no `config` symbol. |
| 810 | - Produces: | 808 | - Produces: |
| 811 | - `type tokenSource struct { key *ecdsa.PrivateKey; keyID, teamID string; now func() time.Time; mu sync.Mutex; cached string; issued time.Time }` | 809 | - `type tokenSource struct { key *ecdsa.PrivateKey; keyID, teamID string; now func() time.Time; mu sync.Mutex; cached string; issued time.Time }` |
| 812 | - `func newTokenSource(key *ecdsa.PrivateKey, keyID, teamID string) *tokenSource` | 810 | - `func newTokenSource(key *ecdsa.PrivateKey, keyID, teamID string) *tokenSource` |
| @@ -1146,9 +1144,15 @@ func TestSendMapsResponses(t *testing.T) { | |||
| 1146 | io.WriteString(w, tc.body) | 1144 | io.WriteString(w, tc.body) |
| 1147 | }) | 1145 | }) |
| 1148 | res, after, err := c.Send(context.Background(), "T", "t", "b", "p") | 1146 | res, after, err := c.Send(context.Background(), "T", "t", "b", "p") |
| 1149 | if err != nil && tc.want != resultDead && tc.want != resultReap { | 1147 | // Only a delivered push has no error. Every other result |
| 1148 | // carries the status and reason, which is what the drainer | ||
| 1149 | // records on the queue row. | ||
| 1150 | if tc.want == resultSent && err != nil { | ||
| 1150 | t.Fatalf("err = %v", err) | 1151 | t.Fatalf("err = %v", err) |
| 1151 | } | 1152 | } |
| 1153 | if tc.want != resultSent && err == nil { | ||
| 1154 | t.Fatalf("want an error explaining %v, got nil", tc.want) | ||
| 1155 | } | ||
| 1152 | if res != tc.want { | 1156 | if res != tc.want { |
| 1153 | t.Fatalf("res = %v, want %v", res, tc.want) | 1157 | t.Fatalf("res = %v, want %v", res, tc.want) |
| 1154 | } | 1158 | } |