Skip to content

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mantzas committed Feb 1, 2016
1 parent db8d170 commit e69ee3a
Showing 1 changed file with 60 additions and 60 deletions.
120 changes: 60 additions & 60 deletions level_logger_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package adaptlog

import (
"testing"
"reflect"
"reflect"
"testing"
)

func TestNewLeveledLoggerWithoutConfigReturnsError(t *testing.T) {
Expand Down Expand Up @@ -103,69 +103,69 @@ func TestNewDefaultLevelLoggerLoggingSucceeds(t *testing.T) {
}

var leveledLoggingTests = []struct {
in Level
out []string
in Level
out []string
}{
{-1, []string { }},
{Panic, []string { PanicMsg, PanicfMsg, PaniclnMsg }},
{Fatal, []string { PanicMsg, PanicfMsg, PaniclnMsg, FatalMsg, FatalfMsg, FatallnMsg }},
{Error, []string { PanicMsg, PanicfMsg, PaniclnMsg, FatalMsg, FatalfMsg, FatallnMsg, ErrorMsg, ErrorfMsg, ErrorlnMsg }},
{Warn, []string { PanicMsg, PanicfMsg, PaniclnMsg, FatalMsg, FatalfMsg, FatallnMsg, ErrorMsg, ErrorfMsg, ErrorlnMsg, WarnMsg, WarnfMsg, WarnlnMsg }},
{Info, []string { PanicMsg, PanicfMsg, PaniclnMsg, FatalMsg, FatalfMsg, FatallnMsg, ErrorMsg, ErrorfMsg, ErrorlnMsg, WarnMsg, WarnfMsg, WarnlnMsg, InfoMsg, InfofMsg, InfolnMsg }},
{Debug, []string { PanicMsg, PanicfMsg, PaniclnMsg, FatalMsg, FatalfMsg, FatallnMsg, ErrorMsg, ErrorfMsg, ErrorlnMsg, WarnMsg, WarnfMsg, WarnlnMsg, InfoMsg, InfofMsg, InfolnMsg, DebugMsg, DebugfMsg, DebuglnMsg }},
{-1, []string{}},
{Panic, []string{PanicMsg, PanicfMsg, PaniclnMsg}},
{Fatal, []string{PanicMsg, PanicfMsg, PaniclnMsg, FatalMsg, FatalfMsg, FatallnMsg}},
{Error, []string{PanicMsg, PanicfMsg, PaniclnMsg, FatalMsg, FatalfMsg, FatallnMsg, ErrorMsg, ErrorfMsg, ErrorlnMsg}},
{Warn, []string{PanicMsg, PanicfMsg, PaniclnMsg, FatalMsg, FatalfMsg, FatallnMsg, ErrorMsg, ErrorfMsg, ErrorlnMsg, WarnMsg, WarnfMsg, WarnlnMsg}},
{Info, []string{PanicMsg, PanicfMsg, PaniclnMsg, FatalMsg, FatalfMsg, FatallnMsg, ErrorMsg, ErrorfMsg, ErrorlnMsg, WarnMsg, WarnfMsg, WarnlnMsg, InfoMsg, InfofMsg, InfolnMsg}},
{Debug, []string{PanicMsg, PanicfMsg, PaniclnMsg, FatalMsg, FatalfMsg, FatallnMsg, ErrorMsg, ErrorfMsg, ErrorlnMsg, WarnMsg, WarnfMsg, WarnlnMsg, InfoMsg, InfofMsg, InfolnMsg, DebugMsg, DebugfMsg, DebuglnMsg}},
}

func TestLevelLoggingTableTest(t *testing.T) {

for _, test := range leveledLoggingTests {
var logger = new(TestLevelLogger)
ConfigLevelLogger(logger, Debug)
lvllogger, err := NewLevelLogger(test.in)

if lvllogger == nil {
t.Fatal("Logger should have been not nil!")
}

if err != nil {
t.Fatal("Should not have returned a error")
}

lvllogger.Panic()
lvllogger.Panicf("Test")
lvllogger.Panicln()

lvllogger.Fatal()
lvllogger.Fatalf("Test")
lvllogger.Fatalln()

lvllogger.Error()
lvllogger.Errorf("Test")
lvllogger.Errorln()

lvllogger.Warn()
lvllogger.Warnf("Test")
lvllogger.Warnln()

lvllogger.Info()
lvllogger.Infof("Test")
lvllogger.Infoln()

lvllogger.Debug()
lvllogger.Debugf("Test")
lvllogger.Debugln()
if len(logger.loggingData) == len(test.out) && len(test.out) == 0 {
if test.in != -1 {
t.Fatal("Level should have been -1!")
}
} else {
if !reflect.DeepEqual(logger.loggingData, test.out) {
t.Fatalf("Logged data is different as expected! actual=%s expected=%s", logger.loggingData, test.out)
}
}
}
for _, test := range leveledLoggingTests {

var logger = new(TestLevelLogger)
ConfigLevelLogger(logger, Debug)

lvllogger, err := NewLevelLogger(test.in)

if lvllogger == nil {
t.Fatal("Logger should have been not nil!")
}

if err != nil {
t.Fatal("Should not have returned a error")
}

lvllogger.Panic()
lvllogger.Panicf("Test")
lvllogger.Panicln()

lvllogger.Fatal()
lvllogger.Fatalf("Test")
lvllogger.Fatalln()

lvllogger.Error()
lvllogger.Errorf("Test")
lvllogger.Errorln()

lvllogger.Warn()
lvllogger.Warnf("Test")
lvllogger.Warnln()

lvllogger.Info()
lvllogger.Infof("Test")
lvllogger.Infoln()

lvllogger.Debug()
lvllogger.Debugf("Test")
lvllogger.Debugln()

if len(logger.loggingData) == len(test.out) && len(test.out) == 0 {
if test.in != -1 {
t.Fatal("Level should have been -1!")
}
} else {
if !reflect.DeepEqual(logger.loggingData, test.out) {
t.Fatalf("Logged data is different as expected! actual=%s expected=%s", logger.loggingData, test.out)
}
}
}
}

const (
Expand Down

0 comments on commit e69ee3a

Please sign in to comment.