update unit testing.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
eb32e593c8
commit
731d884837
|
@ -29,4 +29,4 @@ config.yaml
|
||||||
bin/*
|
bin/*
|
||||||
.DS_Store
|
.DS_Store
|
||||||
coverage.out
|
coverage.out
|
||||||
logs/*
|
gopush/log/*.log
|
||||||
|
|
|
@ -21,7 +21,6 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type LogReq struct {
|
type LogReq struct {
|
||||||
Time string `json:"time"`
|
|
||||||
URI string `json:"uri"`
|
URI string `json:"uri"`
|
||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
IP string `json:"ip"`
|
IP string `json:"ip"`
|
||||||
|
@ -98,7 +97,7 @@ func SetLogLevel(log *logrus.Logger, levelString string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func LogRequest(uri, method, ip string, contentType string, agent string) {
|
func LogRequest(uri string, method string, ip string, contentType string, agent string) {
|
||||||
var output string
|
var output string
|
||||||
log := &LogReq{
|
log := &LogReq{
|
||||||
URI: uri,
|
URI: uri,
|
||||||
|
|
|
@ -25,7 +25,7 @@ func TestSetLogOut(t *testing.T) {
|
||||||
err = SetLogOut(log, "stderr")
|
err = SetLogOut(log, "stderr")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
err = SetLogOut(log, "access.log")
|
err = SetLogOut(log, "log/access.log")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
// missing create logs folder.
|
// missing create logs folder.
|
||||||
|
|
|
@ -62,6 +62,9 @@ func TestRootHandler(t *testing.T) {
|
||||||
|
|
||||||
r := gofight.New()
|
r := gofight.New()
|
||||||
|
|
||||||
|
// log for json
|
||||||
|
PushConf.Log.Format = "json"
|
||||||
|
|
||||||
r.GET("/").
|
r.GET("/").
|
||||||
Run(GetMainEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
|
Run(GetMainEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
|
||||||
data := []byte(r.Body.String())
|
data := []byte(r.Body.String())
|
||||||
|
|
Loading…
Reference in New Issue