@@ -15,7 +15,6 @@ package apns
1515
1616import (
1717 "bytes"
18- "context"
1918 "io"
2019 "net/http"
2120 "strings"
@@ -52,7 +51,7 @@ func TestInit(t *testing.T) {
5251 },
5352 }}
5453 binding := NewAPNS (testLogger ).(* APNS )
55- err := binding .Init (context . Background (), metadata )
54+ err := binding .Init (t . Context (), metadata )
5655 require .NoError (t , err )
5756 assert .Equal (t , developmentPrefix , binding .urlPrefix )
5857 })
@@ -67,7 +66,7 @@ func TestInit(t *testing.T) {
6766 },
6867 }}
6968 binding := NewAPNS (testLogger ).(* APNS )
70- err := binding .Init (context . Background (), metadata )
69+ err := binding .Init (t . Context (), metadata )
7170 require .NoError (t , err )
7271 assert .Equal (t , productionPrefix , binding .urlPrefix )
7372 })
@@ -81,7 +80,7 @@ func TestInit(t *testing.T) {
8180 },
8281 }}
8382 binding := NewAPNS (testLogger ).(* APNS )
84- err := binding .Init (context . Background (), metadata )
83+ err := binding .Init (t . Context (), metadata )
8584 require .NoError (t , err )
8685 assert .Equal (t , productionPrefix , binding .urlPrefix )
8786 })
@@ -94,7 +93,7 @@ func TestInit(t *testing.T) {
9493 },
9594 }}
9695 binding := NewAPNS (testLogger ).(* APNS )
97- err := binding .Init (context . Background (), metadata )
96+ err := binding .Init (t . Context (), metadata )
9897 require .Error (t , err , "the key-id parameter is required" )
9998 })
10099
@@ -107,7 +106,7 @@ func TestInit(t *testing.T) {
107106 },
108107 }}
109108 binding := NewAPNS (testLogger ).(* APNS )
110- err := binding .Init (context . Background (), metadata )
109+ err := binding .Init (t . Context (), metadata )
111110 require .NoError (t , err )
112111 assert .Equal (t , testKeyID , binding .authorizationBuilder .keyID )
113112 })
@@ -120,7 +119,7 @@ func TestInit(t *testing.T) {
120119 },
121120 }}
122121 binding := NewAPNS (testLogger ).(* APNS )
123- err := binding .Init (context . Background (), metadata )
122+ err := binding .Init (t . Context (), metadata )
124123 require .Error (t , err , "the team-id parameter is required" )
125124 })
126125
@@ -133,7 +132,7 @@ func TestInit(t *testing.T) {
133132 },
134133 }}
135134 binding := NewAPNS (testLogger ).(* APNS )
136- err := binding .Init (context . Background (), metadata )
135+ err := binding .Init (t . Context (), metadata )
137136 require .NoError (t , err )
138137 assert .Equal (t , testTeamID , binding .authorizationBuilder .teamID )
139138 })
@@ -146,7 +145,7 @@ func TestInit(t *testing.T) {
146145 },
147146 }}
148147 binding := NewAPNS (testLogger ).(* APNS )
149- err := binding .Init (context . Background (), metadata )
148+ err := binding .Init (t . Context (), metadata )
150149 require .Error (t , err , "the private-key parameter is required" )
151150 })
152151
@@ -159,7 +158,7 @@ func TestInit(t *testing.T) {
159158 },
160159 }}
161160 binding := NewAPNS (testLogger ).(* APNS )
162- err := binding .Init (context . Background (), metadata )
161+ err := binding .Init (t . Context (), metadata )
163162 require .NoError (t , err )
164163 assert .NotNil (t , binding .authorizationBuilder .privateKey )
165164 })
@@ -192,7 +191,7 @@ func TestInvoke(t *testing.T) {
192191 t .Run ("operation must be create" , func (t * testing.T ) {
193192 testBinding := makeTestBinding (t , testLogger )
194193 req := & bindings.InvokeRequest {Operation : bindings .DeleteOperation }
195- _ , err := testBinding .Invoke (context . TODO (), req )
194+ _ , err := testBinding .Invoke (t . Context (), req )
196195 require .Error (t , err , "operation not supported: delete" )
197196 })
198197
@@ -202,7 +201,7 @@ func TestInvoke(t *testing.T) {
202201 Operation : bindings .CreateOperation ,
203202 Metadata : map [string ]string {},
204203 }
205- _ , err := testBinding .Invoke (context . TODO (), req )
204+ _ , err := testBinding .Invoke (t . Context (), req )
206205 require .Error (t , err , "the device-token parameter is required" )
207206 })
208207
@@ -213,7 +212,7 @@ func TestInvoke(t *testing.T) {
213212
214213 return successResponse ()
215214 })
216- _ , _ = testBinding .Invoke (context . TODO (), successRequest )
215+ _ , _ = testBinding .Invoke (t . Context (), successRequest )
217216 })
218217
219218 t .Run ("the push type header is sent" , func (t * testing.T ) {
@@ -224,7 +223,7 @@ func TestInvoke(t *testing.T) {
224223
225224 return successResponse ()
226225 })
227- _ , _ = testBinding .Invoke (context . TODO (), successRequest )
226+ _ , _ = testBinding .Invoke (t . Context (), successRequest )
228227 })
229228
230229 t .Run ("the message ID is sent" , func (t * testing.T ) {
@@ -235,7 +234,7 @@ func TestInvoke(t *testing.T) {
235234
236235 return successResponse ()
237236 })
238- _ , _ = testBinding .Invoke (context . TODO (), successRequest )
237+ _ , _ = testBinding .Invoke (t . Context (), successRequest )
239238 })
240239
241240 t .Run ("the expiration is sent" , func (t * testing.T ) {
@@ -246,7 +245,7 @@ func TestInvoke(t *testing.T) {
246245
247246 return successResponse ()
248247 })
249- _ , _ = testBinding .Invoke (context . TODO (), successRequest )
248+ _ , _ = testBinding .Invoke (t . Context (), successRequest )
250249 })
251250
252251 t .Run ("the priority is sent" , func (t * testing.T ) {
@@ -257,7 +256,7 @@ func TestInvoke(t *testing.T) {
257256
258257 return successResponse ()
259258 })
260- _ , _ = testBinding .Invoke (context . TODO (), successRequest )
259+ _ , _ = testBinding .Invoke (t . Context (), successRequest )
261260 })
262261
263262 t .Run ("the topic is sent" , func (t * testing.T ) {
@@ -268,7 +267,7 @@ func TestInvoke(t *testing.T) {
268267
269268 return successResponse ()
270269 })
271- _ , _ = testBinding .Invoke (context . TODO (), successRequest )
270+ _ , _ = testBinding .Invoke (t . Context (), successRequest )
272271 })
273272
274273 t .Run ("the collapse ID is sent" , func (t * testing.T ) {
@@ -279,15 +278,15 @@ func TestInvoke(t *testing.T) {
279278
280279 return successResponse ()
281280 })
282- _ , _ = testBinding .Invoke (context . TODO (), successRequest )
281+ _ , _ = testBinding .Invoke (t . Context (), successRequest )
283282 })
284283
285284 t .Run ("the message ID is returned" , func (t * testing.T ) {
286285 testBinding := makeTestBinding (t , testLogger )
287286 testBinding .client = newTestClient (func (req * http.Request ) * http.Response {
288287 return successResponse ()
289288 })
290- response , err := testBinding .Invoke (context . TODO (), successRequest )
289+ response , err := testBinding .Invoke (t . Context (), successRequest )
291290 require .NoError (t , err )
292291 assert .NotNil (t , response .Data )
293292 var body notificationResponse
@@ -307,7 +306,7 @@ func TestInvoke(t *testing.T) {
307306 Body : io .NopCloser (strings .NewReader (body )),
308307 }
309308 })
310- _ , err := testBinding .Invoke (context . TODO (), successRequest )
309+ _ , err := testBinding .Invoke (t . Context (), successRequest )
311310 require .Error (t , err , "BadDeviceToken" )
312311 })
313312}
@@ -322,7 +321,7 @@ func makeTestBinding(t *testing.T, log logger.Logger) *APNS {
322321 privateKeyKey : testPrivateKey ,
323322 },
324323 }}
325- err := testBinding .Init (context . Background (), bindingMetadata )
324+ err := testBinding .Init (t . Context (), bindingMetadata )
326325 require .NoError (t , err )
327326
328327 return testBinding
0 commit comments