1
0
mirror of https://github.com/redis/go-redis.git synced 2025-10-18 22:08:50 +03:00
Files
go-redis/logging/logging_test.go
Nedyalko Dyakov 0ef6d0727d feat: RESP3 notifications support & Hitless notifications handling [CAE-1088] & [CAE-1072] (#3418)
- Adds support for handling push notifications with RESP3. 
- Using this support adds handlers for hitless upgrades.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Hristo Temelski <hristo.temelski@redis.com>
2025-09-10 22:18:01 +03:00

60 lines
1.3 KiB
Go

package logging
import "testing"
func TestLogLevel_String(t *testing.T) {
tests := []struct {
level LogLevel
expected string
}{
{LogLevelError, "ERROR"},
{LogLevelWarn, "WARN"},
{LogLevelInfo, "INFO"},
{LogLevelDebug, "DEBUG"},
{LogLevel(99), "UNKNOWN"},
}
for _, test := range tests {
if got := test.level.String(); got != test.expected {
t.Errorf("LogLevel(%d).String() = %q, want %q", test.level, got, test.expected)
}
}
}
func TestLogLevel_IsValid(t *testing.T) {
tests := []struct {
level LogLevel
expected bool
}{
{LogLevelError, true},
{LogLevelWarn, true},
{LogLevelInfo, true},
{LogLevelDebug, true},
{LogLevel(-1), false},
{LogLevel(4), false},
{LogLevel(99), false},
}
for _, test := range tests {
if got := test.level.IsValid(); got != test.expected {
t.Errorf("LogLevel(%d).IsValid() = %v, want %v", test.level, got, test.expected)
}
}
}
func TestLogLevelConstants(t *testing.T) {
// Test that constants have expected values
if LogLevelError != 0 {
t.Errorf("LogLevelError = %d, want 0", LogLevelError)
}
if LogLevelWarn != 1 {
t.Errorf("LogLevelWarn = %d, want 1", LogLevelWarn)
}
if LogLevelInfo != 2 {
t.Errorf("LogLevelInfo = %d, want 2", LogLevelInfo)
}
if LogLevelDebug != 3 {
t.Errorf("LogLevelDebug = %d, want 3", LogLevelDebug)
}
}