mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-05 23:26:38 +08:00
feat(core): bind request services and implement registered tasks
Wire plugin services through Bind/InjectFrom and AppContext so HTTP and workers resolve dependencies after Apply. Register TaskHandler objects with persisted results, and implement send_email_code, mail:send, cleanup_inactive_users, and dispatch_bot_msg.
This commit is contained in:
@@ -229,6 +229,22 @@ func TestTaskExtension(t *testing.T) {
|
||||
assert.False(t, ok)
|
||||
}
|
||||
|
||||
func TestTaskRegisterRejectsNilHandler(t *testing.T) {
|
||||
tr := extpoints.NewTaskRegistry()
|
||||
assert.Panics(t, func() {
|
||||
tr.Register("broken:task", nil)
|
||||
})
|
||||
}
|
||||
|
||||
func TestTaskRegisterRejectsDuplicateType(t *testing.T) {
|
||||
tr := extpoints.NewTaskRegistry()
|
||||
handler := func(ctx context.Context, payload []byte) error { return nil }
|
||||
tr.Register("system:cleanup", handler, extpoints.WithTaskType("system_cleanup"))
|
||||
assert.Panics(t, func() {
|
||||
tr.Register("admin:system_cleanup", handler, extpoints.WithTaskType("system_cleanup"))
|
||||
})
|
||||
}
|
||||
|
||||
func TestScheduleExtension(t *testing.T) {
|
||||
sr := extpoints.NewScheduleRegistry()
|
||||
require.NotNil(t, sr)
|
||||
|
||||
Reference in New Issue
Block a user