Enhance the codebase and test coverage.

This commit is contained in:
2025-02-25 19:56:28 +00:00
parent 942e648d56
commit 3a528b83d9
9 changed files with 318 additions and 63 deletions
+19 -2
View File
@@ -5,7 +5,6 @@ import (
"github.com/stretchr/testify/assert"
)
func TestInitLogger(t *testing.T) {
// Test with debug mode enabled
logger := InitLogger(true)
@@ -50,4 +49,22 @@ func TestLoggingWithNilLogger(t *testing.T) {
// Test passes if we get here without panicking
assert.True(t, true)
}
}
// TestCriticalNilLogger tests that the Critical function doesn't panic with a nil logger
func TestCriticalNilLogger(t *testing.T) {
// Save original logger and restore after test
originalLogger := Logger
defer func() { Logger = originalLogger }()
// Set logger to nil
Logger = nil
// This should not panic
Critical("Critical message", map[string]interface{}{"key": "value"})
// Test passes if we get here without panicking
assert.True(t, true)
}
// Note: We don't test Critical with an actual logger because it calls os.Exit