1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-21 19:30:54 +00:00

Fix JL tests

This commit is contained in:
Ming Deng 2020-09-20 13:15:38 +08:00
parent a1782cc22d
commit 961f300c14
2 changed files with 1 additions and 30 deletions

View File

@ -92,4 +92,4 @@ func TestPatternLogFormatter(t *testing.T) {
if got != want {
t.Errorf("want %s, got %s", want, got)
}
}
}

View File

@ -15,41 +15,12 @@
package logs
import (
"net/http"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
type TestHttpHandler struct {
}
func (t *TestHttpHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
writer.Write([]byte("coming"))
}
func TestJLWriter_WriteMsg(t *testing.T) {
// start sever
http.Handle("/", &TestHttpHandler{})
go http.ListenAndServe(":12124", nil)
jl := newJLWriter()
jl.Init(`{
"webhookurl":"http://localhost:12124/hello",
"redirecturl":"nil",
"imageurl":"a"
}`)
err := jl.WriteMsg(&LogMsg{
Msg: "world",
})
jl.Flush()
jl.Destroy()
assert.Nil(t, err)
}
func TestJLWriter_Format(t *testing.T) {
lg := &LogMsg{
Level: LevelDebug,