MCPcopy Index your code
hub / github.com/MadAppGang/dingo / createTestDmapFile

Function createTestDmapFile

pkg/lsp/sourcemap_cache_test.go:81–107  ·  view source on GitHub ↗

Helper to create a .dmap file in the test workspace

(t *testing.T, workspaceRoot, relPath string)

Source from the content-addressed store, hash-verified

79
80// Helper to create a .dmap file in the test workspace
81func createTestDmapFile(t *testing.T, workspaceRoot, relPath string) {
82 t.Helper()
83
84 dingoSrc := []byte("x := 10\n")
85 goSrc := []byte("x := 10\n")
86
87 mappings := []sourcemap.LineMapping{
88 {DingoLine: 1, GoLineStart: 1, GoLineEnd: 1, Kind: "identity"},
89 }
90
91 writer := dmap.NewWriter(dingoSrc, goSrc)
92 data, err := writer.Write(mappings, nil)
93 if err != nil {
94 t.Fatalf("Failed to create dmap data: %v", err)
95 }
96
97 dmapPath := filepath.Join(workspaceRoot, ".dmap", relPath)
98 dmapDir := filepath.Dir(dmapPath)
99
100 if err := os.MkdirAll(dmapDir, 0755); err != nil {
101 t.Fatalf("Failed to create dmap directory: %v", err)
102 }
103
104 if err := os.WriteFile(dmapPath, data, 0644); err != nil {
105 t.Fatalf("Failed to write dmap file: %v", err)
106 }
107}
108
109func TestSourceMapCacheNew(t *testing.T) {
110 logger := &testLogger{}

Calls 4

WriteMethod · 0.95
NewWriterFunction · 0.92
WriteFileMethod · 0.80
FatalfMethod · 0.65

Tested by

no test coverage detected