feat: add task to cleanup the ActionUser table weekly
test coverage is provided by TestAPICron which runs registerCleanupActionUser()
This commit is contained in:
@@ -22,6 +22,7 @@ func initActionsTasks() {
|
||||
registerScheduleTasks()
|
||||
registerActionsCleanup()
|
||||
registerOfflineRunnersCleanup()
|
||||
registerCleanupActionUser()
|
||||
}
|
||||
|
||||
func registerStopZombieTasks() {
|
||||
@@ -95,3 +96,13 @@ func registerOfflineRunnersCleanup() {
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func registerCleanupActionUser() {
|
||||
RegisterTaskFatal("actions_action_user", &BaseConfig{
|
||||
Enabled: true,
|
||||
RunAtStart: true,
|
||||
Schedule: "@weekly",
|
||||
}, func(ctx context.Context, _ *user_model.User, _ Config) error {
|
||||
return actions_service.CleanupActionUser(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -357,11 +357,11 @@ func TestAPICron(t *testing.T) {
|
||||
AddTokenAuth(token)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
assert.Equal(t, "29", resp.Header().Get("X-Total-Count"))
|
||||
assert.Equal(t, "30", resp.Header().Get("X-Total-Count"))
|
||||
|
||||
var crons []api.Cron
|
||||
DecodeJSON(t, resp, &crons)
|
||||
assert.Len(t, crons, 29)
|
||||
assert.Len(t, crons, 30)
|
||||
})
|
||||
|
||||
t.Run("Execute", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user