From 731d884837b96607e8ee9b8aba1d814bb15a9e9c Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 7 Apr 2016 14:42:38 +0800 Subject: [PATCH] update unit testing. Signed-off-by: Bo-Yi Wu --- .gitignore | 2 +- gorush/log.go | 3 +-- gorush/log/.gitkeep | 0 gorush/log_test.go | 2 +- gorush/server_test.go | 3 +++ 5 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 gorush/log/.gitkeep diff --git a/.gitignore b/.gitignore index 891024d..30aa775 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,4 @@ config.yaml bin/* .DS_Store coverage.out -logs/* +gopush/log/*.log diff --git a/gorush/log.go b/gorush/log.go index 9b731cc..f4cd3f8 100644 --- a/gorush/log.go +++ b/gorush/log.go @@ -21,7 +21,6 @@ var ( ) type LogReq struct { - Time string `json:"time"` URI string `json:"uri"` Method string `json:"method"` IP string `json:"ip"` @@ -98,7 +97,7 @@ func SetLogLevel(log *logrus.Logger, levelString string) error { 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 log := &LogReq{ URI: uri, diff --git a/gorush/log/.gitkeep b/gorush/log/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/gorush/log_test.go b/gorush/log_test.go index 42ecb76..dd08f3d 100644 --- a/gorush/log_test.go +++ b/gorush/log_test.go @@ -25,7 +25,7 @@ func TestSetLogOut(t *testing.T) { err = SetLogOut(log, "stderr") assert.Nil(t, err) - err = SetLogOut(log, "access.log") + err = SetLogOut(log, "log/access.log") assert.Nil(t, err) // missing create logs folder. diff --git a/gorush/server_test.go b/gorush/server_test.go index ac1b72f..fb8af9f 100644 --- a/gorush/server_test.go +++ b/gorush/server_test.go @@ -62,6 +62,9 @@ func TestRootHandler(t *testing.T) { r := gofight.New() + // log for json + PushConf.Log.Format = "json" + r.GET("/"). Run(GetMainEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) { data := []byte(r.Body.String())