mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-07 08:32:16 +00:00
## Issue Gitea does not display a clear error message when a user tries to create a cleanup rule for a package type that already has an existing cleanup rule. Although the duplicate rule is detected, the user is not informed why the cleanup rule cannot be created. ## Solution Add a user-facing error message when a cleanup rule already exists for the selected package type. Also add an integration test to verify that the appropriate error message is displayed when attempting to create a duplicate cleanup rule. Fixes #37820
This commit is contained in:
@@ -29,6 +29,33 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPackageCleanupRuleDuplicateType(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4})
|
||||
session := loginUser(t, user.Name)
|
||||
|
||||
// Create the first cleanup rule for the generic package type.
|
||||
req := NewRequestWithValues(t, "POST", "/user/settings/packages/rules/add", map[string]string{
|
||||
"type": "generic",
|
||||
"action": "save",
|
||||
"keep_count": "0",
|
||||
"remove_days": "0",
|
||||
})
|
||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
|
||||
// Try to create another cleanup rule for the same package type.
|
||||
req = NewRequestWithValues(t, "POST", "/user/settings/packages/rules/add", map[string]string{
|
||||
"type": "generic",
|
||||
"action": "save",
|
||||
"keep_count": "0",
|
||||
"remove_days": "0",
|
||||
})
|
||||
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
assert.Contains(t, resp.Body.String(), "A cleanup rule for this package type already exists.")
|
||||
}
|
||||
|
||||
func TestPackageAPI(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user