@xdfnet/ispeak 1.6.10 → 1.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.go +0 -6
- package/main_test.go +5 -10
- package/package.json +1 -1
package/main.go
CHANGED
|
@@ -96,12 +96,6 @@ func (e *TaskEngine) Start() {
|
|
|
96
96
|
func (e *TaskEngine) Submit(text string, voice VoiceInfo, cfg Config) uint64 {
|
|
97
97
|
e.mu.Lock()
|
|
98
98
|
|
|
99
|
-
// 新任务进来先删所有未开始的任务。
|
|
100
|
-
for _, id := range e.pending {
|
|
101
|
-
delete(e.tasks, id)
|
|
102
|
-
log.Printf("删除待执行任务: id=%d", id)
|
|
103
|
-
}
|
|
104
|
-
e.pending = e.pending[:0]
|
|
105
99
|
|
|
106
100
|
e.nextID++
|
|
107
101
|
task := &Task{
|
package/main_test.go
CHANGED
|
@@ -13,7 +13,7 @@ import (
|
|
|
13
13
|
"time"
|
|
14
14
|
)
|
|
15
15
|
|
|
16
|
-
func
|
|
16
|
+
func TestSubmitKeepsAllPendingTasks(t *testing.T) {
|
|
17
17
|
e := NewTaskEngine()
|
|
18
18
|
e.synthesizeStreamFn = func(ctx context.Context, cfg Config, text string, voice *VoiceInfo, onAudio func([]byte) error) error {
|
|
19
19
|
return onAudio([]byte("ok"))
|
|
@@ -28,16 +28,11 @@ func TestSubmitClearsPendingOnly(t *testing.T) {
|
|
|
28
28
|
|
|
29
29
|
e.mu.Lock()
|
|
30
30
|
defer e.mu.Unlock()
|
|
31
|
-
if len(e.pending) !=
|
|
32
|
-
t.Fatalf("expected
|
|
33
|
-
}
|
|
34
|
-
id := e.pending[0]
|
|
35
|
-
task, ok := e.tasks[id]
|
|
36
|
-
if !ok {
|
|
37
|
-
t.Fatalf("expected pending task exists")
|
|
31
|
+
if len(e.pending) != 2 {
|
|
32
|
+
t.Fatalf("expected 2 pending, got %d", len(e.pending))
|
|
38
33
|
}
|
|
39
|
-
if
|
|
40
|
-
t.Fatalf("expected
|
|
34
|
+
if e.latestID != 2 {
|
|
35
|
+
t.Fatalf("expected latestID 2, got %d", e.latestID)
|
|
41
36
|
}
|
|
42
37
|
}
|
|
43
38
|
|
package/package.json
CHANGED