6
6
package github
7
7
8
8
import (
9
- "context"
10
9
"errors"
11
10
"fmt"
12
11
"net/http"
@@ -36,7 +35,7 @@ func TestActionsService_ListArtifacts(t *testing.T) {
36
35
Name : Ptr ("TheArtifact" ),
37
36
ListOptions : ListOptions {Page : 2 },
38
37
}
39
- ctx := context . Background ()
38
+ ctx := t . Context ()
40
39
artifacts , _ , err := client .Actions .ListArtifacts (ctx , "o" , "r" , opts )
41
40
if err != nil {
42
41
t .Errorf ("Actions.ListArtifacts returned error: %v" , err )
@@ -66,7 +65,7 @@ func TestActionsService_ListArtifacts_invalidOwner(t *testing.T) {
66
65
t .Parallel ()
67
66
client , _ , _ := setup (t )
68
67
69
- ctx := context . Background ()
68
+ ctx := t . Context ()
70
69
_ , _ , err := client .Actions .ListArtifacts (ctx , "%" , "r" , nil )
71
70
testURLParseError (t , err )
72
71
}
@@ -75,7 +74,7 @@ func TestActionsService_ListArtifacts_invalidRepo(t *testing.T) {
75
74
t .Parallel ()
76
75
client , _ , _ := setup (t )
77
76
78
- ctx := context . Background ()
77
+ ctx := t . Context ()
79
78
_ , _ , err := client .Actions .ListArtifacts (ctx , "o" , "%" , nil )
80
79
testURLParseError (t , err )
81
80
}
@@ -89,7 +88,7 @@ func TestActionsService_ListArtifacts_notFound(t *testing.T) {
89
88
w .WriteHeader (http .StatusNotFound )
90
89
})
91
90
92
- ctx := context . Background ()
91
+ ctx := t . Context ()
93
92
artifacts , resp , err := client .Actions .ListArtifacts (ctx , "o" , "r" , nil )
94
93
if err == nil {
95
94
t .Error ("Expected HTTP 404 response" )
@@ -118,7 +117,7 @@ func TestActionsService_ListWorkflowRunArtifacts(t *testing.T) {
118
117
})
119
118
120
119
opts := & ListOptions {Page : 2 }
121
- ctx := context . Background ()
120
+ ctx := t . Context ()
122
121
artifacts , _ , err := client .Actions .ListWorkflowRunArtifacts (ctx , "o" , "r" , 1 , opts )
123
122
if err != nil {
124
123
t .Errorf ("Actions.ListWorkflowRunArtifacts returned error: %v" , err )
@@ -148,7 +147,7 @@ func TestActionsService_ListWorkflowRunArtifacts_invalidOwner(t *testing.T) {
148
147
t .Parallel ()
149
148
client , _ , _ := setup (t )
150
149
151
- ctx := context . Background ()
150
+ ctx := t . Context ()
152
151
_ , _ , err := client .Actions .ListWorkflowRunArtifacts (ctx , "%" , "r" , 1 , nil )
153
152
testURLParseError (t , err )
154
153
}
@@ -157,7 +156,7 @@ func TestActionsService_ListWorkflowRunArtifacts_invalidRepo(t *testing.T) {
157
156
t .Parallel ()
158
157
client , _ , _ := setup (t )
159
158
160
- ctx := context . Background ()
159
+ ctx := t . Context ()
161
160
_ , _ , err := client .Actions .ListWorkflowRunArtifacts (ctx , "o" , "%" , 1 , nil )
162
161
testURLParseError (t , err )
163
162
}
@@ -171,7 +170,7 @@ func TestActionsService_ListWorkflowRunArtifacts_notFound(t *testing.T) {
171
170
w .WriteHeader (http .StatusNotFound )
172
171
})
173
172
174
- ctx := context . Background ()
173
+ ctx := t . Context ()
175
174
artifacts , resp , err := client .Actions .ListWorkflowRunArtifacts (ctx , "o" , "r" , 1 , nil )
176
175
if err == nil {
177
176
t .Error ("Expected HTTP 404 response" )
@@ -199,7 +198,7 @@ func TestActionsService_GetArtifact(t *testing.T) {
199
198
}` )
200
199
})
201
200
202
- ctx := context . Background ()
201
+ ctx := t . Context ()
203
202
artifact , _ , err := client .Actions .GetArtifact (ctx , "o" , "r" , 1 )
204
203
if err != nil {
205
204
t .Errorf ("Actions.GetArtifact returned error: %v" , err )
@@ -235,7 +234,7 @@ func TestActionsService_GetArtifact_invalidOwner(t *testing.T) {
235
234
t .Parallel ()
236
235
client , _ , _ := setup (t )
237
236
238
- ctx := context . Background ()
237
+ ctx := t . Context ()
239
238
_ , _ , err := client .Actions .GetArtifact (ctx , "%" , "r" , 1 )
240
239
testURLParseError (t , err )
241
240
}
@@ -244,7 +243,7 @@ func TestActionsService_GetArtifact_invalidRepo(t *testing.T) {
244
243
t .Parallel ()
245
244
client , _ , _ := setup (t )
246
245
247
- ctx := context . Background ()
246
+ ctx := t . Context ()
248
247
_ , _ , err := client .Actions .GetArtifact (ctx , "o" , "%" , 1 )
249
248
testURLParseError (t , err )
250
249
}
@@ -258,7 +257,7 @@ func TestActionsService_GetArtifact_notFound(t *testing.T) {
258
257
w .WriteHeader (http .StatusNotFound )
259
258
})
260
259
261
- ctx := context . Background ()
260
+ ctx := t . Context ()
262
261
artifact , resp , err := client .Actions .GetArtifact (ctx , "o" , "r" , 1 )
263
262
if err == nil {
264
263
t .Error ("Expected HTTP 404 response" )
@@ -299,7 +298,7 @@ func TestActionsService_DownloadArtifact(t *testing.T) {
299
298
http .Redirect (w , r , "https://github.com/artifact" , http .StatusFound )
300
299
})
301
300
302
- ctx := context . Background ()
301
+ ctx := t . Context ()
303
302
url , resp , err := client .Actions .DownloadArtifact (ctx , "o" , "r" , 1 , 1 )
304
303
if err != nil {
305
304
t .Errorf ("Actions.DownloadArtifact returned error: %v" , err )
@@ -355,7 +354,7 @@ func TestActionsService_DownloadArtifact_invalidOwner(t *testing.T) {
355
354
client , _ , _ := setup (t )
356
355
client .RateLimitRedirectionalEndpoints = tc .respectRateLimits
357
356
358
- ctx := context . Background ()
357
+ ctx := t . Context ()
359
358
_ , _ , err := client .Actions .DownloadArtifact (ctx , "%" , "r" , 1 , 1 )
360
359
testURLParseError (t , err )
361
360
})
@@ -384,7 +383,7 @@ func TestActionsService_DownloadArtifact_invalidRepo(t *testing.T) {
384
383
client , _ , _ := setup (t )
385
384
client .RateLimitRedirectionalEndpoints = tc .respectRateLimits
386
385
387
- ctx := context . Background ()
386
+ ctx := t . Context ()
388
387
_ , _ , err := client .Actions .DownloadArtifact (ctx , "o" , "%" , 1 , 1 )
389
388
testURLParseError (t , err )
390
389
})
@@ -418,7 +417,7 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_dontFollowRedire
418
417
http .Redirect (w , r , "https://github.com/artifact" , http .StatusMovedPermanently )
419
418
})
420
419
421
- ctx := context . Background ()
420
+ ctx := t . Context ()
422
421
_ , resp , _ := client .Actions .DownloadArtifact (ctx , "o" , "r" , 1 , 0 )
423
422
if resp .StatusCode != http .StatusMovedPermanently {
424
423
t .Errorf ("Actions.DownloadArtifact return status %d, want %d" , resp .StatusCode , http .StatusMovedPermanently )
@@ -459,7 +458,7 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_followRedirects(
459
458
http .Redirect (w , r , "https://github.com/artifact" , http .StatusFound )
460
459
})
461
460
462
- ctx := context . Background ()
461
+ ctx := t . Context ()
463
462
url , resp , err := client .Actions .DownloadArtifact (ctx , "o" , "r" , 1 , 1 )
464
463
if err != nil {
465
464
t .Errorf ("Actions.DownloadArtifact return error: %v" , err )
@@ -507,7 +506,7 @@ func TestActionsService_DownloadArtifact_unexpectedCode(t *testing.T) {
507
506
w .WriteHeader (http .StatusNoContent )
508
507
})
509
508
510
- ctx := context . Background ()
509
+ ctx := t . Context ()
511
510
url , resp , err := client .Actions .DownloadArtifact (ctx , "o" , "r" , 1 , 1 )
512
511
if err == nil {
513
512
t .Fatal ("Actions.DownloadArtifact should return error on unexpected code" )
@@ -533,7 +532,7 @@ func TestActionsService_DeleteArtifact(t *testing.T) {
533
532
testMethod (t , r , "DELETE" )
534
533
})
535
534
536
- ctx := context . Background ()
535
+ ctx := t . Context ()
537
536
_ , err := client .Actions .DeleteArtifact (ctx , "o" , "r" , 1 )
538
537
if err != nil {
539
538
t .Errorf ("Actions.DeleteArtifact return error: %v" , err )
@@ -554,7 +553,7 @@ func TestActionsService_DeleteArtifact_invalidOwner(t *testing.T) {
554
553
t .Parallel ()
555
554
client , _ , _ := setup (t )
556
555
557
- ctx := context . Background ()
556
+ ctx := t . Context ()
558
557
_ , err := client .Actions .DeleteArtifact (ctx , "%" , "r" , 1 )
559
558
testURLParseError (t , err )
560
559
}
@@ -563,7 +562,7 @@ func TestActionsService_DeleteArtifact_invalidRepo(t *testing.T) {
563
562
t .Parallel ()
564
563
client , _ , _ := setup (t )
565
564
566
- ctx := context . Background ()
565
+ ctx := t . Context ()
567
566
_ , err := client .Actions .DeleteArtifact (ctx , "o" , "%" , 1 )
568
567
testURLParseError (t , err )
569
568
}
@@ -577,7 +576,7 @@ func TestActionsService_DeleteArtifact_notFound(t *testing.T) {
577
576
w .WriteHeader (http .StatusNotFound )
578
577
})
579
578
580
- ctx := context . Background ()
579
+ ctx := t . Context ()
581
580
resp , err := client .Actions .DeleteArtifact (ctx , "o" , "r" , 1 )
582
581
if err == nil {
583
582
t .Error ("Expected HTTP 404 response" )
0 commit comments