(t *testing.T)
| 178 | } |
| 179 | |
| 180 | func TestClientPushWithContextWithTimeout(t *testing.T) { |
| 181 | const timeout = time.Nanosecond |
| 182 | n := mockNotification() |
| 183 | var apnsID = "02ABC856-EF8D-4E49-8F15-7B8A61D978D6" |
| 184 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 185 | w.Header().Set("Content-Type", "application/json; charset=utf-8") |
| 186 | w.Header().Set("apns-id", apnsID) |
| 187 | w.WriteHeader(http.StatusOK) |
| 188 | })) |
| 189 | defer server.Close() |
| 190 | |
| 191 | ctx, cancel := context.WithTimeout(context.Background(), timeout) |
| 192 | time.Sleep(timeout) |
| 193 | res, err := mockClient(server.URL).PushWithContext(ctx, n) |
| 194 | assert.Error(t, err) |
| 195 | assert.Nil(t, res) |
| 196 | cancel() |
| 197 | } |
| 198 | |
| 199 | func TestClientPushWithContext(t *testing.T) { |
| 200 | n := mockNotification() |
nothing calls this directly
no test coverage detected