MCPcopy
hub / github.com/MadAppGang/dingo / TestSourceMapCacheCacheHit

Function TestSourceMapCacheCacheHit

pkg/lsp/sourcemap_cache_test.go:179–210  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

177}
178
179func TestSourceMapCacheCacheHit(t *testing.T) {
180 workspaceRoot, cleanup := setupTestWorkspace(t)
181 defer cleanup()
182
183 // Create a .dmap file
184 createTestDmapFile(t, workspaceRoot, "cached.dmap")
185
186 logger := &testLogger{}
187 cache, err := NewSourceMapCache(logger)
188 if err != nil {
189 t.Fatalf("NewSourceMapCache failed: %v", err)
190 }
191
192 goPath := filepath.Join(workspaceRoot, "cached.go")
193
194 // First get - cache miss, loads from disk
195 reader1, err := cache.Get(goPath)
196 if err != nil {
197 t.Fatalf("First Get failed: %v", err)
198 }
199
200 // Second get - should hit cache
201 reader2, err := cache.Get(goPath)
202 if err != nil {
203 t.Fatalf("Second Get failed: %v", err)
204 }
205
206 // Should return the same reader instance (pointer equality)
207 if reader1 != reader2 {
208 t.Error("Cache should return same reader instance")
209 }
210}
211
212func TestSourceMapCacheInvalidate(t *testing.T) {
213 workspaceRoot, cleanup := setupTestWorkspace(t)

Callers

nothing calls this directly

Calls 6

GetMethod · 0.95
setupTestWorkspaceFunction · 0.85
createTestDmapFileFunction · 0.85
NewSourceMapCacheFunction · 0.85
FatalfMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected