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:
parent
3bbc482879
commit
cc1fdc84ca
108 changed files with 712 additions and 794 deletions
|
@ -4,7 +4,6 @@
|
|||
package git
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
|
@ -18,7 +17,7 @@ func TestGetNotes(t *testing.T) {
|
|||
defer bareRepo1.Close()
|
||||
|
||||
note := Note{}
|
||||
err = GetNote(context.Background(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", ¬e)
|
||||
err = GetNote(t.Context(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", ¬e)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, []byte("Note contents\n"), note.Message)
|
||||
assert.Equal(t, "Vladimir Panteleev", note.Commit.Author.Name)
|
||||
|
@ -31,10 +30,10 @@ func TestGetNestedNotes(t *testing.T) {
|
|||
defer repo.Close()
|
||||
|
||||
note := Note{}
|
||||
err = GetNote(context.Background(), repo, "3e668dbfac39cbc80a9ff9c61eb565d944453ba4", ¬e)
|
||||
err = GetNote(t.Context(), repo, "3e668dbfac39cbc80a9ff9c61eb565d944453ba4", ¬e)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, []byte("Note 2"), note.Message)
|
||||
err = GetNote(context.Background(), repo, "ba0a96fa63532d6c5087ecef070b0250ed72fa47", ¬e)
|
||||
err = GetNote(t.Context(), repo, "ba0a96fa63532d6c5087ecef070b0250ed72fa47", ¬e)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, []byte("Note 1"), note.Message)
|
||||
}
|
||||
|
@ -46,7 +45,7 @@ func TestGetNonExistentNotes(t *testing.T) {
|
|||
defer bareRepo1.Close()
|
||||
|
||||
note := Note{}
|
||||
err = GetNote(context.Background(), bareRepo1, "non_existent_sha", ¬e)
|
||||
err = GetNote(t.Context(), bareRepo1, "non_existent_sha", ¬e)
|
||||
assert.Error(t, err)
|
||||
assert.IsType(t, ErrNotExist{}, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue