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

Function TestSourceMapCacheGetSuccess

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

Source from the content-addressed store, hash-verified

137}
138
139func TestSourceMapCacheGetSuccess(t *testing.T) {
140 workspaceRoot, cleanup := setupTestWorkspace(t)
141 defer cleanup()
142
143 // Create a .dmap file
144 createTestDmapFile(t, workspaceRoot, "test.dmap")
145
146 logger := &testLogger{}
147 cache, err := NewSourceMapCache(logger)
148 if err != nil {
149 t.Fatalf("NewSourceMapCache failed: %v", err)
150 }
151
152 // Get the source map using the .go file path
153 goPath := filepath.Join(workspaceRoot, "test.go")
154 reader, err := cache.Get(goPath)
155 if err != nil {
156 t.Fatalf("Get failed: %v", err)
157 }
158
159 if reader == nil {
160 t.Fatal("Expected non-nil reader")
161 }
162
163 // v2 format stores line mappings - verify via line lookup API
164 // The test dmap has: DingoLine: 1, GoLineStart: 1, GoLineEnd: 1, Kind: "identity"
165 dingoLine, kind := reader.GoLineToDingoLine(1)
166 if dingoLine != 1 {
167 t.Errorf("Expected dingo line 1, got %d", dingoLine)
168 }
169 if kind != "identity" {
170 t.Errorf("Expected kind 'identity', got %q", kind)
171 }
172
173 // Cache should now have 1 entry
174 if cache.Size() != 1 {
175 t.Errorf("Cache size should be 1, got %d", cache.Size())
176 }
177}
178
179func TestSourceMapCacheCacheHit(t *testing.T) {
180 workspaceRoot, cleanup := setupTestWorkspace(t)

Callers

nothing calls this directly

Calls 8

GetMethod · 0.95
SizeMethod · 0.95
setupTestWorkspaceFunction · 0.85
createTestDmapFileFunction · 0.85
NewSourceMapCacheFunction · 0.85
GoLineToDingoLineMethod · 0.80
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected