Add HTTP /v1 MVC, TCP send path, groups with server-side member-avatar collage, object-storage upload, and friends/favorites around the architecture-v3 layout. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
884 B
Go
44 lines
884 B
Go
package logger
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"go.uber.org/zap/zapcore"
|
|
)
|
|
|
|
func TestNewWritesRotatingFile(t *testing.T) {
|
|
dir := t.TempDir()
|
|
path := filepath.Join(dir, "app.log")
|
|
log, closeFn := New(&Options{
|
|
Level: "info",
|
|
Console: false,
|
|
File: FileOptions{Path: path, MaxSizeMB: 1, MaxBackups: 1, MaxAgeDays: 1},
|
|
})
|
|
log.Info("hello_file")
|
|
if err := closeFn(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
raw, err := os.ReadFile(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.Contains(string(raw), "hello_file") {
|
|
t.Fatalf("file content %s", raw)
|
|
}
|
|
}
|
|
|
|
func TestParseLevel(t *testing.T) {
|
|
if parseLevel("debug") != zapcore.DebugLevel || parseLevel("DEBUG") != zapcore.DebugLevel {
|
|
t.Fatal("debug")
|
|
}
|
|
if parseLevel("error") != zapcore.ErrorLevel {
|
|
t.Fatal("error")
|
|
}
|
|
if parseLevel("info") != zapcore.InfoLevel {
|
|
t.Fatal("info")
|
|
}
|
|
}
|