1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 08:10:58 +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

@ -15,41 +15,12 @@
package logs package logs
import ( import (
"net/http"
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert" "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) { func TestJLWriter_Format(t *testing.T) {
lg := &LogMsg{ lg := &LogMsg{
Level: LevelDebug, Level: LevelDebug,