MCPcopy
hub / github.com/sideshow/apns2 / TestClientPushWithContextWithTimeout

Function TestClientPushWithContextWithTimeout

client_test.go:180–197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

178}
179
180func 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
199func TestClientPushWithContext(t *testing.T) {
200 n := mockNotification()

Callers

nothing calls this directly

Calls 3

mockNotificationFunction · 0.85
mockClientFunction · 0.85
PushWithContextMethod · 0.80

Tested by

no test coverage detected