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/url | |
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/url')
-rw-r--r-- | modules/git/url/url_test.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/modules/git/url/url_test.go b/modules/git/url/url_test.go index 9c020adb4d..681da564f9 100644 --- a/modules/git/url/url_test.go +++ b/modules/git/url/url_test.go @@ -179,7 +179,7 @@ func TestParseRepositoryURL(t *testing.T) { ctxReq := &http.Request{URL: ctxURL, Header: http.Header{}} ctxReq.Host = ctxURL.Host ctxReq.Header.Add("X-Forwarded-Proto", ctxURL.Scheme) - ctx := context.WithValue(context.Background(), httplib.RequestContextKey, ctxReq) + ctx := context.WithValue(t.Context(), httplib.RequestContextKey, ctxReq) cases := []struct { input string ownerName, repoName, remaining string @@ -249,19 +249,19 @@ func TestMakeRepositoryBaseLink(t *testing.T) { defer test.MockVariableValue(&setting.AppURL, "https://localhost:3000/subpath")() defer test.MockVariableValue(&setting.AppSubURL, "/subpath")() - u, err := ParseRepositoryURL(context.Background(), "https://localhost:3000/subpath/user/repo.git") + u, err := ParseRepositoryURL(t.Context(), "https://localhost:3000/subpath/user/repo.git") assert.NoError(t, err) assert.Equal(t, "/subpath/user/repo", MakeRepositoryWebLink(u)) - u, err = ParseRepositoryURL(context.Background(), "https://github.com/owner/repo.git") + u, err = ParseRepositoryURL(t.Context(), "https://github.com/owner/repo.git") assert.NoError(t, err) assert.Equal(t, "https://github.com/owner/repo", MakeRepositoryWebLink(u)) - u, err = ParseRepositoryURL(context.Background(), "git@github.com:owner/repo.git") + u, err = ParseRepositoryURL(t.Context(), "git@github.com:owner/repo.git") assert.NoError(t, err) assert.Equal(t, "https://github.com/owner/repo", MakeRepositoryWebLink(u)) - u, err = ParseRepositoryURL(context.Background(), "git+ssh://other:123/owner/repo.git") + u, err = ParseRepositoryURL(t.Context(), "git+ssh://other:123/owner/repo.git") assert.NoError(t, err) assert.Equal(t, "https://other/owner/repo", MakeRepositoryWebLink(u)) } |