1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Use test context in tests and new loop system in benchmarks (#33648)

Replace all contexts in tests with go1.24 t.Context()

---------

Co-authored-by: Giteabot <teabot@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
TheFox0x7
2025-02-20 10:57:40 +01:00
committed by GitHub
parent 3bbc482879
commit cc1fdc84ca
108 changed files with 712 additions and 794 deletions

View File

@@ -4,7 +4,6 @@
package integration
import (
"context"
"encoding/base64"
"fmt"
"net/http"
@@ -37,7 +36,7 @@ func TestJobWithNeeds(t *testing.T) {
{
treePath: ".gitea/workflows/job-with-needs.yml",
fileContent: `name: job-with-needs
on:
on:
push:
paths:
- '.gitea/workflows/job-with-needs.yml'
@@ -68,7 +67,7 @@ jobs:
{
treePath: ".gitea/workflows/job-with-needs-fail.yml",
fileContent: `name: job-with-needs-fail
on:
on:
push:
paths:
- '.gitea/workflows/job-with-needs-fail.yml'
@@ -96,7 +95,7 @@ jobs:
{
treePath: ".gitea/workflows/job-with-needs-fail-if.yml",
fileContent: `name: job-with-needs-fail-if
on:
on:
push:
paths:
- '.gitea/workflows/job-with-needs-fail-if.yml'
@@ -181,7 +180,7 @@ func TestJobNeedsMatrix(t *testing.T) {
{
treePath: ".gitea/workflows/jobs-outputs-with-matrix.yml",
fileContent: `name: jobs-outputs-with-matrix
on:
on:
push:
paths:
- '.gitea/workflows/jobs-outputs-with-matrix.yml'
@@ -200,7 +199,7 @@ jobs:
id: gen_output
run: |
version="${{ matrix.version }}"
echo "output_${version}=${version}" >> "$GITHUB_OUTPUT"
echo "output_${version}=${version}" >> "$GITHUB_OUTPUT"
job2:
runs-on: ubuntu-latest
needs: [job1]
@@ -247,7 +246,7 @@ jobs:
{
treePath: ".gitea/workflows/jobs-outputs-with-matrix-failure.yml",
fileContent: `name: jobs-outputs-with-matrix-failure
on:
on:
push:
paths:
- '.gitea/workflows/jobs-outputs-with-matrix-failure.yml'
@@ -266,7 +265,7 @@ jobs:
id: gen_output
run: |
version="${{ matrix.version }}"
echo "output_${version}=${version}" >> "$GITHUB_OUTPUT"
echo "output_${version}=${version}" >> "$GITHUB_OUTPUT"
job2:
runs-on: ubuntu-latest
if: ${{ always() }}
@@ -405,7 +404,7 @@ jobs:
actionTask := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionTask{ID: task.Id})
actionRunJob := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunJob{ID: actionTask.JobID})
actionRun := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{ID: actionRunJob.RunID})
assert.NoError(t, actionRun.LoadAttributes(context.Background()))
assert.NoError(t, actionRun.LoadAttributes(t.Context()))
assert.Equal(t, user2.Name, gtCtx["actor"].GetStringValue())
assert.Equal(t, setting.AppURL+"api/v1", gtCtx["api_url"].GetStringValue())