Skip to content

Commit 7cb6ff3

Browse files
committed
test
1 parent 1a95cd1 commit 7cb6ff3

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

models/db/iterate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"xorm.io/builder"
1212
)
1313

14-
// Iterate iterate all the Bean object
14+
// Iterate iterates all the Bean object
1515
func Iterate[Bean any](ctx context.Context, cond builder.Cond, f func(ctx context.Context, bean *Bean) error) error {
1616
var start int
1717
batchSize := setting.Database.IterateBufferSize

services/packages/cleanup/cleanup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
rpm_service "code.gitea.io/gitea/services/packages/rpm"
2323
)
2424

25-
// Task method to execute cleanup rules and cleanup expired package data
25+
// CleanupTask executes cleanup rules and cleanup expired package data
2626
func CleanupTask(ctx context.Context, olderThan time.Duration) error {
2727
if err := ExecuteCleanupRules(ctx); err != nil {
2828
return err

tests/integration/api_packages_debian_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
user_model "code.gitea.io/gitea/models/user"
2020
"code.gitea.io/gitea/modules/base"
2121
debian_module "code.gitea.io/gitea/modules/packages/debian"
22+
packages_cleanup_service "code.gitea.io/gitea/services/packages/cleanup"
2223
"code.gitea.io/gitea/tests"
2324

2425
"github.com/blakesmith/ar"
@@ -263,4 +264,24 @@ func TestPackageDebian(t *testing.T) {
263264
assert.Contains(t, body, "Components: "+strings.Join(components, " ")+"\n")
264265
assert.Contains(t, body, "Architectures: "+architectures[1]+"\n")
265266
})
267+
268+
t.Run("Cleanup", func(t *testing.T) {
269+
rule := &packages.PackageCleanupRule{
270+
Enabled: true,
271+
RemovePattern: `.*`,
272+
MatchFullName: true,
273+
OwnerID: user.ID,
274+
Type: packages.TypeDebian,
275+
}
276+
277+
_, err := packages.InsertCleanupRule(db.DefaultContext, rule)
278+
assert.NoError(t, err)
279+
280+
uploadURL := fmt.Sprintf("%s/pool/%s/%s/upload", rootURL, "test", "main")
281+
req := NewRequestWithBody(t, "PUT", uploadURL, createArchive(packageName, packageVersion, "all")).AddBasicAuth(user.Name)
282+
MakeRequest(t, req, http.StatusCreated)
283+
284+
err = packages_cleanup_service.CleanupTask(db.DefaultContext, 0)
285+
assert.NoError(t, err)
286+
})
266287
}

0 commit comments

Comments
 (0)