优化结构
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package worker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
taskbiz "kra/internal/biz/task"
|
||||
platformtask "kra/pkg/task"
|
||||
)
|
||||
|
||||
func TestTaskMethodsReportUnavailableDependencies(t *testing.T) {
|
||||
registry := platformtask.NewRegistry()
|
||||
(&TaskMethods{}).RegisterTasks(registry)
|
||||
|
||||
for _, name := range []string{taskbiz.TaskMethodClearDB, taskbiz.TaskMethodUploads} {
|
||||
method, ok := registry.Lookup(name)
|
||||
if !ok {
|
||||
t.Fatalf("task method %q was not registered", name)
|
||||
}
|
||||
if err := method(context.Background(), json.RawMessage(`{}`)); err == nil {
|
||||
t.Fatalf("task method %q returned nil with missing dependencies", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user