init
This commit is contained in:
58
logger_test.go
Normal file
58
logger_test.go
Normal file
@ -0,0 +1,58 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"git.belvedersky.ru/common/logger/service"
|
||||
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
var (
|
||||
cfg = service.Config{
|
||||
System: "test",
|
||||
Development: true,
|
||||
Directory: "test_logs",
|
||||
LogFileName: "test",
|
||||
PanicFileName: "test_panic",
|
||||
Webhook: "https://devtest.galamart.ru/bus/pub?topic=error&channel=error",
|
||||
}
|
||||
)
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
|
||||
s := New(cfg, nil)
|
||||
if s.cfg != cfg {
|
||||
t.Errorf("NewLoggerService() = %v, want %v", s.cfg, &cfg)
|
||||
}
|
||||
if s.cfg != cfg {
|
||||
t.Errorf("Log file is nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
|
||||
s := New(cfg, nil)
|
||||
if s.cfg != cfg {
|
||||
t.Errorf("NewLoggerService() = %v, want %v", s.cfg, &cfg)
|
||||
}
|
||||
testLogger := s.Create("test")
|
||||
if testLogger.Log == nil {
|
||||
t.Errorf("Log is nil")
|
||||
}
|
||||
testLogger.Print(service.LogStruct{Message: "test", Color: color.FgBlue})
|
||||
}
|
||||
|
||||
func TestFileUpdate(t *testing.T) {
|
||||
s := New(cfg, nil)
|
||||
if s.cfg != cfg {
|
||||
t.Errorf("NewLoggerService() = %v, want %v", s.cfg, &cfg)
|
||||
}
|
||||
if err := s.FileUpdate(true, nil); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := os.RemoveAll("test_logs"); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user