Browse Source
- Introduced test files for the blossom and database packages to improve test coverage and ensure functionality. - Updated logging practices by suppressing unnecessary log outputs during tests to enhance clarity and focus on relevant information. - Refactored error handling in the `handle-message` and `handle-req` functions to avoid logging expected context cancellation errors during shutdown. - Bumped version to v0.25.2 to reflect these updates.main
25 changed files with 431 additions and 107 deletions
@ -0,0 +1,31 @@ |
|||||||
|
package blossom |
||||||
|
|
||||||
|
import ( |
||||||
|
"io" |
||||||
|
"os" |
||||||
|
"testing" |
||||||
|
|
||||||
|
"lol.mleku.dev" |
||||||
|
"lol.mleku.dev/log" |
||||||
|
) |
||||||
|
|
||||||
|
func TestMain(m *testing.M) { |
||||||
|
// Disable all logging during tests unless explicitly enabled
|
||||||
|
if os.Getenv("TEST_LOG") == "" { |
||||||
|
// Set log level to Off to suppress all logs
|
||||||
|
lol.SetLogLevel("off") |
||||||
|
// Also redirect output to discard
|
||||||
|
lol.Writer = io.Discard |
||||||
|
// Disable all log printers
|
||||||
|
log.T = lol.GetNullPrinter() |
||||||
|
log.D = lol.GetNullPrinter() |
||||||
|
log.I = lol.GetNullPrinter() |
||||||
|
log.W = lol.GetNullPrinter() |
||||||
|
log.E = lol.GetNullPrinter() |
||||||
|
log.F = lol.GetNullPrinter() |
||||||
|
} |
||||||
|
|
||||||
|
// Run tests
|
||||||
|
os.Exit(m.Run()) |
||||||
|
} |
||||||
|
|
||||||
@ -0,0 +1,31 @@ |
|||||||
|
package encryption |
||||||
|
|
||||||
|
import ( |
||||||
|
"io" |
||||||
|
"os" |
||||||
|
"testing" |
||||||
|
|
||||||
|
"lol.mleku.dev" |
||||||
|
"lol.mleku.dev/log" |
||||||
|
) |
||||||
|
|
||||||
|
func TestMain(m *testing.M) { |
||||||
|
// Disable all logging during tests unless explicitly enabled
|
||||||
|
if os.Getenv("TEST_LOG") == "" { |
||||||
|
// Set log level to Off to suppress all logs
|
||||||
|
lol.SetLogLevel("off") |
||||||
|
// Also redirect output to discard
|
||||||
|
lol.Writer = io.Discard |
||||||
|
// Disable all log printers
|
||||||
|
log.T = lol.GetNullPrinter() |
||||||
|
log.D = lol.GetNullPrinter() |
||||||
|
log.I = lol.GetNullPrinter() |
||||||
|
log.W = lol.GetNullPrinter() |
||||||
|
log.E = lol.GetNullPrinter() |
||||||
|
log.F = lol.GetNullPrinter() |
||||||
|
} |
||||||
|
|
||||||
|
// Run tests
|
||||||
|
os.Exit(m.Run()) |
||||||
|
} |
||||||
|
|
||||||
@ -0,0 +1,34 @@ |
|||||||
|
package database |
||||||
|
|
||||||
|
import ( |
||||||
|
"io" |
||||||
|
"os" |
||||||
|
"testing" |
||||||
|
|
||||||
|
"lol.mleku.dev" |
||||||
|
"lol.mleku.dev/log" |
||||||
|
) |
||||||
|
|
||||||
|
func TestMain(m *testing.M) { |
||||||
|
// Disable all logging during tests unless explicitly enabled
|
||||||
|
if os.Getenv("TEST_LOG") == "" { |
||||||
|
// Set log level to Off to suppress all logs
|
||||||
|
lol.SetLogLevel("off") |
||||||
|
// Also redirect output to discard
|
||||||
|
lol.Writer = io.Discard |
||||||
|
// Disable all log printers
|
||||||
|
log.T = lol.GetNullPrinter() |
||||||
|
log.D = lol.GetNullPrinter() |
||||||
|
log.I = lol.GetNullPrinter() |
||||||
|
log.W = lol.GetNullPrinter() |
||||||
|
log.E = lol.GetNullPrinter() |
||||||
|
log.F = lol.GetNullPrinter() |
||||||
|
|
||||||
|
// Also suppress badger logs
|
||||||
|
os.Setenv("BADGER_LOG_LEVEL", "CRITICAL") |
||||||
|
} |
||||||
|
|
||||||
|
// Run tests
|
||||||
|
os.Exit(m.Run()) |
||||||
|
} |
||||||
|
|
||||||
@ -0,0 +1,31 @@ |
|||||||
|
package policy |
||||||
|
|
||||||
|
import ( |
||||||
|
"io" |
||||||
|
"os" |
||||||
|
"testing" |
||||||
|
|
||||||
|
"lol.mleku.dev" |
||||||
|
"lol.mleku.dev/log" |
||||||
|
) |
||||||
|
|
||||||
|
func TestMain(m *testing.M) { |
||||||
|
// Disable all logging during tests unless explicitly enabled
|
||||||
|
if os.Getenv("TEST_LOG") == "" { |
||||||
|
// Set log level to Off to suppress all logs
|
||||||
|
lol.SetLogLevel("off") |
||||||
|
// Also redirect output to discard
|
||||||
|
lol.Writer = io.Discard |
||||||
|
// Disable all log printers
|
||||||
|
log.T = lol.GetNullPrinter() |
||||||
|
log.D = lol.GetNullPrinter() |
||||||
|
log.I = lol.GetNullPrinter() |
||||||
|
log.W = lol.GetNullPrinter() |
||||||
|
log.E = lol.GetNullPrinter() |
||||||
|
log.F = lol.GetNullPrinter() |
||||||
|
} |
||||||
|
|
||||||
|
// Run tests
|
||||||
|
os.Exit(m.Run()) |
||||||
|
} |
||||||
|
|
||||||
Loading…
Reference in new issue