返回 DeepSeek-Reasonix
session_recovery_event_order_test.go
根目录 / desktop / session_recovery_event_order_test.go
1 package main
2
3 import (
4 "context"
5 "testing"
6 "time"
7 )
8
9 func TestSessionRecoveredEventPrecedesImmediateCatalogRevision(t *testing.T) {
10 events := make(chan string, 4)
11 app := &App{ctx: context.Background()}
12 app.runtimeEvents.emit = func(_ context.Context, name string, _ ...any) {
13 events <- name
14 }
15 app.projectTreeChangedHook = func() {
16 app.emitProjectTreeChangedV2(1, []string{""}, "test-immediate-revision")
17 }
18
19 app.emitSessionRecoveredAndRefresh("", sessionRecoveryEvent{RecoveryPath: "/s/fork.jsonl", TopicID: "topic"})
20
21 next := func() string {
22 t.Helper()
23 select {
24 case name := <-events:
25 return name
26 case <-time.After(time.Second):
27 t.Fatal("timed out waiting for runtime event")
28 return ""
29 }
30 }
31 if got := next(); got != "session:recovered" {
32 t.Fatalf("first event = %q, want session:recovered", got)
33 }
34 if got := next(); got != "project-tree:changed-v2" {
35 t.Fatalf("second event = %q, want project-tree:changed-v2", got)
36 }
37 }
38
38 lines GO