mirror of
https://github.com/astaxie/beego.git
synced 2024-11-06 04:30:55 +00:00
Fix JL tests
This commit is contained in:
parent
a1782cc22d
commit
961f300c14
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user