Test that the logger gets called appropriately
(t *testing.T)
| 444 | |
| 445 | // Test that the logger gets called appropriately |
| 446 | func 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 | } |
nothing calls this directly
no test coverage detected