mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-15 04:13:42 +00:00
test: use t.Context() instead of context.Background() (#1306)
The test context is cancelled when the test ends, so anything still holding it stops instead of leaking into the next test. Uses inside `t.Cleanup`, `defer` and `go func` blocks are left alone, as the context is already cancelled there. Stacked on https://gitea.com/gitea/runner/pulls/1305. Assisted-by: Codet Co-authored-by: bircni <[email protected]> Reviewed-on: https://gitea.com/gitea/runner/pulls/1306 Reviewed-by: bircni <[email protected]>
This commit is contained in:
1 parent
160e18e705
commit
c3c647ef83
38 files changed
+288
-301
No files matched your search
@@ -43,7 +43,7 @@ func TestJobLog_MirrorsUploadedRows(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
cfg.Log.Job.Dir = t.TempDir()
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
t.Cleanup(cancel)
|
||||
task := &runnerv1.Task{Id: 41, Context: &structpb.Struct{}, Secrets: map[string]string{"TOKEN": "s3cret-value"}}
|
||||
reporter := NewReporter(ctx, cancel, client, task, cfg)
|
||||
|
||||
Reference in new issue
Block a user