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

Function TestSourceMapCacheLogging

pkg/lsp/sourcemap_cache_test.go:446–480  ·  view source on GitHub ↗

Test that the logger gets called appropriately

(t *testing.T)

Source from the content-addressed store, hash-verified

444
445// Test that the logger gets called appropriately
446func TestSourceMapCacheLogging(t *testing.T) {
447 workspaceRoot, cleanup := setupTestWorkspace(t)
448 defer cleanup()
449
450 createTestDmapFile(t, workspaceRoot, "logging.dmap")
451
452 logger := &recordingLogger{}
453 cache, err := NewSourceMapCache(logger)
454 if err != nil {
455 t.Fatalf("NewSourceMapCache failed: %v", err)
456 }
457
458 goPath := filepath.Join(workspaceRoot, "logging.go")
459
460 // First get - should log load
461 _, err = cache.Get(goPath)
462 if err != nil {
463 t.Fatalf("Get failed: %v", err)
464 }
465
466 // Check that info message was logged
467 logger.mu.Lock()
468 hasLoadMessage := false
469 for _, msg := range logger.messages {
470 if len(msg) > 5 && msg[:5] == "INFO:" {
471 hasLoadMessage = true
472 break
473 }
474 }
475 logger.mu.Unlock()
476
477 if !hasLoadMessage {
478 t.Error("Expected INFO log message for source map load")
479 }
480}

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