diff options
author | TheFox0x7 <thefox0x7@gmail.com> | 2025-02-20 10:57:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-20 09:57:40 +0000 |
commit | cc1fdc84ca0e51e25b6190010144af10e28ca082 (patch) | |
tree | 6bf02091d5f72aebb562193bc1985035d1556228 /modules/git/commit_info_test.go | |
parent | 3bbc4828792cf741e6684d13429aeabb271ca1ad (diff) | |
download | gitea-cc1fdc84ca0e51e25b6190010144af10e28ca082.tar.gz gitea-cc1fdc84ca0e51e25b6190010144af10e28ca082.zip |
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>
Diffstat (limited to 'modules/git/commit_info_test.go')
-rw-r--r-- | modules/git/commit_info_test.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/modules/git/commit_info_test.go b/modules/git/commit_info_test.go index 1e331fac00..ba518ab245 100644 --- a/modules/git/commit_info_test.go +++ b/modules/git/commit_info_test.go @@ -4,7 +4,6 @@ package git import ( - "context" "path/filepath" "testing" "time" @@ -83,7 +82,7 @@ func testGetCommitsInfo(t *testing.T, repo1 *Repository) { } // FIXME: Context.TODO() - if graceful has started we should use its Shutdown context otherwise use install signals in TestMain. - commitsInfo, treeCommit, err := entries.GetCommitsInfo(context.TODO(), commit, testCase.Path) + commitsInfo, treeCommit, err := entries.GetCommitsInfo(t.Context(), commit, testCase.Path) assert.NoError(t, err, "Unable to get commit information for entries of subtree: %s in commit: %s from testcase due to error: %v", testCase.Path, testCase.CommitID, err) if err != nil { t.FailNow() @@ -159,8 +158,8 @@ func BenchmarkEntries_GetCommitsInfo(b *testing.B) { entries.Sort() b.ResetTimer() b.Run(benchmark.name, func(b *testing.B) { - for i := 0; i < b.N; i++ { - _, _, err := entries.GetCommitsInfo(context.Background(), commit, "") + for b.Loop() { + _, _, err := entries.GetCommitsInfo(b.Context(), commit, "") if err != nil { b.Fatal(err) } |