mirror of
https://github.com/goharbor/harbor
synced 2024-09-20 21:34:15 +00:00
Merge pull request #9405 from heww/speed-up-test
perf(test): speed up TestAddBlobsToProject test in dao pkg
This commit is contained in:
commit
6447294741
|
@ -54,7 +54,7 @@ func AddBlobsToProject(projectID int64, blobs ...*models.Blob) (int64, error) {
|
|||
})
|
||||
}
|
||||
|
||||
cnt, err := GetOrmer().InsertMulti(10, projectBlobs)
|
||||
cnt, err := GetOrmer().InsertMulti(100, projectBlobs)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "duplicate key value violates unique constraint") {
|
||||
return cnt, ErrDupRows
|
||||
|
|
|
@ -49,19 +49,20 @@ func TestAddBlobsToProject(t *testing.T) {
|
|||
OwnerID: 1,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
defer DeleteProject(pid)
|
||||
|
||||
for i := 0; i < 88888; i++ {
|
||||
blobsCount := 88888
|
||||
for i := 0; i < blobsCount; i++ {
|
||||
blob := &models.Blob{
|
||||
ID: int64(100000 + i), // Use fake id to speed this test
|
||||
Digest: digest.FromString(utils.GenerateRandomString()).String(),
|
||||
Size: 100,
|
||||
}
|
||||
_, err := AddBlob(blob)
|
||||
require.Nil(t, err)
|
||||
blobs = append(blobs, blob)
|
||||
}
|
||||
cnt, err := AddBlobsToProject(pid, blobs...)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, cnt, int64(88888))
|
||||
require.Equal(t, cnt, int64(blobsCount))
|
||||
}
|
||||
|
||||
func TestHasBlobInProject(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user