mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
simplify omit server errors test code 🎶
Former-commit-id: 2fb491cb4bccc5e8164bb19acd209954f5abd50c
This commit is contained in:
parent
69a2b3c81e
commit
654d9e630d
|
@ -4,20 +4,15 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
stdContext "context"
|
stdContext "context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/kataras/iris"
|
"github.com/kataras/iris"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func logger(app *iris.Application) *bytes.Buffer {
|
func logger(app *iris.Application) *bytes.Buffer {
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
app.Logger().Formatter = &logrus.TextFormatter{
|
|
||||||
DisableColors: true,
|
|
||||||
DisableSorting: true,
|
|
||||||
DisableTimestamp: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
app.Logger().Out = buf
|
app.Logger().Out = buf
|
||||||
|
|
||||||
|
@ -48,11 +43,14 @@ func TestListenAddr(t *testing.T) {
|
||||||
|
|
||||||
// println(log.Bytes())
|
// println(log.Bytes())
|
||||||
// println(len(log.Bytes()))
|
// println(len(log.Bytes()))
|
||||||
expected := fmt.Sprintln("level=error msg=\"" + iris.ErrServerClosed.Error() + "\" ")
|
|
||||||
|
expected := fmt.Sprintln("\"" + iris.ErrServerClosed.Error() + "\" ")
|
||||||
// println([]byte(expected))
|
// println([]byte(expected))
|
||||||
// println(len([]byte(expected)))
|
// println(len([]byte(expected)))
|
||||||
|
|
||||||
if got := log.String(); expected != got {
|
got := log.String()
|
||||||
|
got = strings.Split(got, "msg=")[1]
|
||||||
|
if expected != got {
|
||||||
t.Fatalf("expecting to log the:\n'%s'\ninstead of:\n'%s'", expected, got)
|
t.Fatalf("expecting to log the:\n'%s'\ninstead of:\n'%s'", expected, got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user