(t *testing.T)
| 137 | } |
| 138 | |
| 139 | func 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 | |
| 179 | func TestSourceMapCacheCacheHit(t *testing.T) { |
| 180 | workspaceRoot, cleanup := setupTestWorkspace(t) |
nothing calls this directly
no test coverage detected