Skip to content

Commit e56d378

Browse files
authored
refactor: Do not call teardown manually in tests (#3296)
1 parent 0024ad2 commit e56d378

File tree

150 files changed

+1614
-2928
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+1614
-2928
lines changed

github/actions_artifacts_test.go

+21-42
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import (
1717
)
1818

1919
func TestActionsService_ListArtifacts(t *testing.T) {
20-
client, mux, _, teardown := setup()
21-
defer teardown()
20+
client, mux, _ := setup(t)
2221

2322
mux.HandleFunc("/repos/o/r/actions/artifacts", func(w http.ResponseWriter, r *http.Request) {
2423
testMethod(t, r, "GET")
@@ -59,26 +58,23 @@ func TestActionsService_ListArtifacts(t *testing.T) {
5958
}
6059

6160
func TestActionsService_ListArtifacts_invalidOwner(t *testing.T) {
62-
client, _, _, teardown := setup()
63-
defer teardown()
61+
client, _, _ := setup(t)
6462

6563
ctx := context.Background()
6664
_, _, err := client.Actions.ListArtifacts(ctx, "%", "r", nil)
6765
testURLParseError(t, err)
6866
}
6967

7068
func TestActionsService_ListArtifacts_invalidRepo(t *testing.T) {
71-
client, _, _, teardown := setup()
72-
defer teardown()
69+
client, _, _ := setup(t)
7370

7471
ctx := context.Background()
7572
_, _, err := client.Actions.ListArtifacts(ctx, "o", "%", nil)
7673
testURLParseError(t, err)
7774
}
7875

7976
func TestActionsService_ListArtifacts_notFound(t *testing.T) {
80-
client, mux, _, teardown := setup()
81-
defer teardown()
77+
client, mux, _ := setup(t)
8278

8379
mux.HandleFunc("/repos/o/r/actions/artifacts", func(w http.ResponseWriter, r *http.Request) {
8480
testMethod(t, r, "GET")
@@ -99,8 +95,7 @@ func TestActionsService_ListArtifacts_notFound(t *testing.T) {
9995
}
10096

10197
func TestActionsService_ListWorkflowRunArtifacts(t *testing.T) {
102-
client, mux, _, teardown := setup()
103-
defer teardown()
98+
client, mux, _ := setup(t)
10499

105100
mux.HandleFunc("/repos/o/r/actions/runs/1/artifacts", func(w http.ResponseWriter, r *http.Request) {
106101
testMethod(t, r, "GET")
@@ -141,26 +136,23 @@ func TestActionsService_ListWorkflowRunArtifacts(t *testing.T) {
141136
}
142137

143138
func TestActionsService_ListWorkflowRunArtifacts_invalidOwner(t *testing.T) {
144-
client, _, _, teardown := setup()
145-
defer teardown()
139+
client, _, _ := setup(t)
146140

147141
ctx := context.Background()
148142
_, _, err := client.Actions.ListWorkflowRunArtifacts(ctx, "%", "r", 1, nil)
149143
testURLParseError(t, err)
150144
}
151145

152146
func TestActionsService_ListWorkflowRunArtifacts_invalidRepo(t *testing.T) {
153-
client, _, _, teardown := setup()
154-
defer teardown()
147+
client, _, _ := setup(t)
155148

156149
ctx := context.Background()
157150
_, _, err := client.Actions.ListWorkflowRunArtifacts(ctx, "o", "%", 1, nil)
158151
testURLParseError(t, err)
159152
}
160153

161154
func TestActionsService_ListWorkflowRunArtifacts_notFound(t *testing.T) {
162-
client, mux, _, teardown := setup()
163-
defer teardown()
155+
client, mux, _ := setup(t)
164156

165157
mux.HandleFunc("/repos/o/r/actions/runs/1/artifacts", func(w http.ResponseWriter, r *http.Request) {
166158
testMethod(t, r, "GET")
@@ -181,8 +173,7 @@ func TestActionsService_ListWorkflowRunArtifacts_notFound(t *testing.T) {
181173
}
182174

183175
func TestActionsService_GetArtifact(t *testing.T) {
184-
client, mux, _, teardown := setup()
185-
defer teardown()
176+
client, mux, _ := setup(t)
186177

187178
mux.HandleFunc("/repos/o/r/actions/artifacts/1", func(w http.ResponseWriter, r *http.Request) {
188179
testMethod(t, r, "GET")
@@ -228,26 +219,23 @@ func TestActionsService_GetArtifact(t *testing.T) {
228219
}
229220

230221
func TestActionsService_GetArtifact_invalidOwner(t *testing.T) {
231-
client, _, _, teardown := setup()
232-
defer teardown()
222+
client, _, _ := setup(t)
233223

234224
ctx := context.Background()
235225
_, _, err := client.Actions.GetArtifact(ctx, "%", "r", 1)
236226
testURLParseError(t, err)
237227
}
238228

239229
func TestActionsService_GetArtifact_invalidRepo(t *testing.T) {
240-
client, _, _, teardown := setup()
241-
defer teardown()
230+
client, _, _ := setup(t)
242231

243232
ctx := context.Background()
244233
_, _, err := client.Actions.GetArtifact(ctx, "o", "%", 1)
245234
testURLParseError(t, err)
246235
}
247236

248237
func TestActionsService_GetArtifact_notFound(t *testing.T) {
249-
client, mux, _, teardown := setup()
250-
defer teardown()
238+
client, mux, _ := setup(t)
251239

252240
mux.HandleFunc("/repos/o/r/actions/artifacts/1", func(w http.ResponseWriter, r *http.Request) {
253241
testMethod(t, r, "GET")
@@ -268,8 +256,7 @@ func TestActionsService_GetArtifact_notFound(t *testing.T) {
268256
}
269257

270258
func TestActionsService_DownloadArtifact(t *testing.T) {
271-
client, mux, _, teardown := setup()
272-
defer teardown()
259+
client, mux, _ := setup(t)
273260

274261
mux.HandleFunc("/repos/o/r/actions/artifacts/1/zip", func(w http.ResponseWriter, r *http.Request) {
275262
testMethod(t, r, "GET")
@@ -307,26 +294,23 @@ func TestActionsService_DownloadArtifact(t *testing.T) {
307294
}
308295

309296
func TestActionsService_DownloadArtifact_invalidOwner(t *testing.T) {
310-
client, _, _, teardown := setup()
311-
defer teardown()
297+
client, _, _ := setup(t)
312298

313299
ctx := context.Background()
314300
_, _, err := client.Actions.DownloadArtifact(ctx, "%", "r", 1, 1)
315301
testURLParseError(t, err)
316302
}
317303

318304
func TestActionsService_DownloadArtifact_invalidRepo(t *testing.T) {
319-
client, _, _, teardown := setup()
320-
defer teardown()
305+
client, _, _ := setup(t)
321306

322307
ctx := context.Background()
323308
_, _, err := client.Actions.DownloadArtifact(ctx, "o", "%", 1, 1)
324309
testURLParseError(t, err)
325310
}
326311

327312
func TestActionsService_DownloadArtifact_StatusMovedPermanently_dontFollowRedirects(t *testing.T) {
328-
client, mux, _, teardown := setup()
329-
defer teardown()
313+
client, mux, _ := setup(t)
330314

331315
mux.HandleFunc("/repos/o/r/actions/artifacts/1/zip", func(w http.ResponseWriter, r *http.Request) {
332316
testMethod(t, r, "GET")
@@ -341,8 +325,7 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_dontFollowRedire
341325
}
342326

343327
func TestActionsService_DownloadArtifact_StatusMovedPermanently_followRedirects(t *testing.T) {
344-
client, mux, serverURL, teardown := setup()
345-
defer teardown()
328+
client, mux, serverURL := setup(t)
346329

347330
mux.HandleFunc("/repos/o/r/actions/artifacts/1/zip", func(w http.ResponseWriter, r *http.Request) {
348331
testMethod(t, r, "GET")
@@ -369,8 +352,7 @@ func TestActionsService_DownloadArtifact_StatusMovedPermanently_followRedirects(
369352
}
370353

371354
func TestActionsService_DeleteArtifact(t *testing.T) {
372-
client, mux, _, teardown := setup()
373-
defer teardown()
355+
client, mux, _ := setup(t)
374356

375357
mux.HandleFunc("/repos/o/r/actions/artifacts/1", func(w http.ResponseWriter, r *http.Request) {
376358
testMethod(t, r, "DELETE")
@@ -394,26 +376,23 @@ func TestActionsService_DeleteArtifact(t *testing.T) {
394376
}
395377

396378
func TestActionsService_DeleteArtifact_invalidOwner(t *testing.T) {
397-
client, _, _, teardown := setup()
398-
defer teardown()
379+
client, _, _ := setup(t)
399380

400381
ctx := context.Background()
401382
_, err := client.Actions.DeleteArtifact(ctx, "%", "r", 1)
402383
testURLParseError(t, err)
403384
}
404385

405386
func TestActionsService_DeleteArtifact_invalidRepo(t *testing.T) {
406-
client, _, _, teardown := setup()
407-
defer teardown()
387+
client, _, _ := setup(t)
408388

409389
ctx := context.Background()
410390
_, err := client.Actions.DeleteArtifact(ctx, "o", "%", 1)
411391
testURLParseError(t, err)
412392
}
413393

414394
func TestActionsService_DeleteArtifact_notFound(t *testing.T) {
415-
client, mux, _, teardown := setup()
416-
defer teardown()
395+
client, mux, _ := setup(t)
417396

418397
mux.HandleFunc("/repos/o/r/actions/artifacts/1", func(w http.ResponseWriter, r *http.Request) {
419398
testMethod(t, r, "DELETE")

0 commit comments

Comments
 (0)