返回 DeepSeek-Reasonix
topic_state_catalog_test.go
根目录 / desktop / topic_state_catalog_test.go
1 package main
2
3 import (
4 "testing"
5
6 "reasonix/internal/config"
7 )
8
9 // A remote project group's qualified root ("remote-project:<host>:<workspace>")
10 // is not a filesystem path. Listing must answer with an empty page instead of
11 // building a topic-state scope from it — on Windows the colon is an invalid
12 // path component and the legacy metadata read failed with a user-visible
13 // "topic metadata is unavailable (io)" toast right after the connect wizard.
14 func TestListProjectTopicsAnswersRemoteRootWithEmptyPage(t *testing.T) {
15 isolateDesktopUserDirs(t)
16 app := NewApp()
17 page, err := app.ListProjectTopics(ProjectTopicPageRequest{
18 Scope: "project",
19 WorkspaceRoot: "remote-project:gpu-box:/home/dev/app",
20 Limit: 50,
21 })
22 if err != nil {
23 t.Fatalf("remote root listing failed: %v", err)
24 }
25 if page.Items == nil || len(page.Items) != 0 {
26 t.Fatalf("remote root page items = %#v, want an empty page", page.Items)
27 }
28 }
29
30 func TestListProjectTreeSkipsRemoteTopicState(t *testing.T) {
31 isolateDesktopUserDirs(t)
32 const remoteRoot = "remote-project:gpu-box:/home/dev/app"
33 if err := editUserConfig(func(c *config.Config) error {
34 if err := c.UpsertRemoteHost(config.RemoteHostEntry{Name: "gpu-box", Host: "127.0.0.1"}); err != nil {
35 return err
36 }
37 return c.UpsertRemoteProject(config.RemoteProjectEntry{HostID: "gpu-box", Workspace: "/home/dev/app"})
38 }); err != nil {
39 t.Fatal(err)
40 }
41
42 found := false
43 for _, node := range NewApp().ListProjectTree() {
44 if node.Remote == nil {
45 continue
46 }
47 found = true
48 if len(node.Children) != 0 {
49 t.Fatalf("remote project children = %#v, want none from local topic state", node.Children)
50 }
51 }
52 if !found {
53 t.Fatal("compatibility tree omitted the remote project group")
54 }
55
56 desktopTopicState.mu.Lock()
57 opened := desktopTopicState.scopes[config.DesktopTopicStatePath(remoteRoot)] != nil
58 desktopTopicState.mu.Unlock()
59 if opened {
60 t.Fatalf("compatibility tree opened local topic state for virtual root %q", remoteRoot)
61 }
62 }
63
63 lines GO