MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / TestLogger_ConcurrentAccess

Function TestLogger_ConcurrentAccess

internal/logger/logger_test.go:432–464  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

430}
431
432func TestLogger_ConcurrentAccess(t *testing.T) {
433 var buf bytes.Buffer
434 config := &Config{
435 Level: LevelInfo,
436 Output: &buf,
437 }
438
439 logger, err := NewLogger(config)
440 require.NoError(t, err)
441 defer logger.Close()
442
443 // Test concurrent logging
444 done := make(chan bool, 10)
445
446 for i := 0; i < 10; i++ {
447 go func(id int) {
448 logger.Info("concurrent message %d", id)
449 done <- true
450 }(i)
451 }
452
453 // Wait for all goroutines to complete
454 for i := 0; i < 10; i++ {
455 <-done
456 }
457
458 output := buf.String()
459
460 // Should contain all messages
461 for i := 0; i < 10; i++ {
462 assert.Contains(t, output, "concurrent message")
463 }
464}
465
466// TestLogger_InterfaceCompliance verifies that Logger implements interfaces.Logger.
467func TestLogger_InterfaceCompliance(t *testing.T) {

Callers

nothing calls this directly

Calls 4

CloseMethod · 0.95
InfoMethod · 0.95
NewLoggerFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected