-
Notifications
You must be signed in to change notification settings - Fork 513
Expand file tree
/
Copy pathdeepseek_tui_provider_test.go
More file actions
160 lines (140 loc) · 4.98 KB
/
Copy pathdeepseek_tui_provider_test.go
File metadata and controls
160 lines (140 loc) · 4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package parser
import (
"context"
"crypto/sha256"
"fmt"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestDeepSeekTUIProviderFactoryReplacesLegacyAdapter(t *testing.T) {
factory, ok := ProviderFactoryByType(AgentDeepSeekTUI)
require.True(t, ok)
require.NotNil(t, factory)
provider, ok := NewProvider(AgentDeepSeekTUI, ProviderConfig{
Roots: []string{t.TempDir()},
Machine: "devbox",
})
require.True(t, ok)
require.NotNil(t, provider)
}
func TestDeepSeekTUIProviderSourceMethods(t *testing.T) {
root := t.TempDir()
sourcePath := filepath.Join(root, "session_123.json")
writeSourceFile(t, sourcePath, deepSeekTUIProviderFixture())
writeSourceFile(t, filepath.Join(root, "latest.json"), "{}\n")
writeSourceFile(t, filepath.Join(root, "offline_queue.json"), "{}\n")
writeSourceFile(t, filepath.Join(root, "nested", "session_456.json"), "{}\n")
provider, ok := NewProvider(AgentDeepSeekTUI, ProviderConfig{
Roots: []string{root},
Machine: "devbox",
})
require.True(t, ok)
discovered, err := provider.Discover(context.Background())
require.NoError(t, err)
require.Len(t, discovered, 1)
assert.Equal(t, AgentDeepSeekTUI, discovered[0].Provider)
assert.Equal(t, sourcePath, discovered[0].DisplayPath)
found, ok, err := provider.FindSource(context.Background(), FindSourceRequest{
FullSessionID: "host~deepseek-tui:session_123",
})
require.NoError(t, err)
require.True(t, ok)
assert.Equal(t, sourcePath, found.DisplayPath)
found, ok, err = provider.FindSource(context.Background(), FindSourceRequest{
FingerprintKey: sourcePath,
})
require.NoError(t, err)
require.True(t, ok)
assert.Equal(t, sourcePath, found.DisplayPath)
require.NoError(t, os.Remove(sourcePath))
changed, err := provider.SourcesForChangedPath(
context.Background(),
ChangedPathRequest{Path: sourcePath, EventKind: "remove", WatchRoot: root},
)
require.NoError(t, err)
require.Len(t, changed, 1)
assert.Equal(t, sourcePath, changed[0].DisplayPath)
}
func TestDeepSeekTUIProviderSourceMethodsFollowSymlinkedSessionFile(t *testing.T) {
root := t.TempDir()
targetDir := t.TempDir()
targetPath := filepath.Join(targetDir, "session_123.json")
sourcePath := filepath.Join(root, "session_123.json")
writeSourceFile(t, targetPath, deepSeekTUIProviderFixture())
if err := os.Symlink(targetPath, sourcePath); err != nil {
t.Skipf("symlink not supported: %v", err)
}
provider, ok := NewProvider(AgentDeepSeekTUI, ProviderConfig{
Roots: []string{root},
Machine: "devbox",
})
require.True(t, ok)
discovered, err := provider.Discover(context.Background())
require.NoError(t, err)
require.Len(t, discovered, 1)
assert.Equal(t, sourcePath, discovered[0].DisplayPath)
found, ok, err := provider.FindSource(context.Background(), FindSourceRequest{
FullSessionID: "host~deepseek-tui:session_123",
})
require.NoError(t, err)
require.True(t, ok)
assert.Equal(t, sourcePath, found.DisplayPath)
changed, err := provider.SourcesForChangedPath(
context.Background(),
ChangedPathRequest{Path: sourcePath, EventKind: "write", WatchRoot: root},
)
require.NoError(t, err)
require.Len(t, changed, 1)
assert.Equal(t, sourcePath, changed[0].DisplayPath)
}
func TestDeepSeekTUIProviderParse(t *testing.T) {
root := t.TempDir()
sourcePath := filepath.Join(root, "session_123.json")
content := deepSeekTUIProviderFixture()
writeSourceFile(t, sourcePath, content)
provider, ok := NewProvider(AgentDeepSeekTUI, ProviderConfig{
Roots: []string{root},
Machine: "devbox",
})
require.True(t, ok)
sources, err := provider.Discover(context.Background())
require.NoError(t, err)
require.Len(t, sources, 1)
fingerprint, err := provider.Fingerprint(context.Background(), sources[0])
require.NoError(t, err)
outcome, err := provider.Parse(context.Background(), ParseRequest{
Source: sources[0],
Fingerprint: fingerprint,
})
require.NoError(t, err)
require.True(t, outcome.ResultSetComplete)
require.Len(t, outcome.Results, 1)
assert.Equal(t, DataVersionCurrent, outcome.Results[0].DataVersion)
assert.Equal(t, "deepseek-tui:session_123", outcome.Results[0].Result.Session.ID)
assert.Equal(t, "sample_project", outcome.Results[0].Result.Session.Project)
assert.Equal(t, "devbox", outcome.Results[0].Result.Session.Machine)
assert.Equal(t,
fmt.Sprintf("%x", sha256.Sum256([]byte(content))),
outcome.Results[0].Result.Session.File.Hash,
)
assert.Len(t, outcome.Results[0].Result.Messages, 2)
}
func deepSeekTUIProviderFixture() string {
return `{
"metadata": {
"id": "session_123",
"title": "Investigate DeepSeek TUI",
"created_at": "2026-06-01T10:00:00Z",
"updated_at": "2026-06-01T10:02:00Z",
"model": "deepseek-chat",
"workspace": "/Users/alice/code/sample-project"
},
"messages": [
{"role": "user", "content": "Inspect server logs", "timestamp": "2026-06-01T10:00:05Z"},
{"role": "assistant", "content": [{"type": "text", "text": "The server failed during startup."}], "timestamp": "2026-06-01T10:00:10Z"}
]
}`
}