Skip to content

Commit 2e1d7fa

Browse files
author
zouyixian
committed
server.go测试用例
1 parent 9062bac commit 2e1d7fa

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎server_test.go‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/devfeel/dotweb/session"
55
"github.com/devfeel/dotweb/test"
66
"testing"
7+
"time"
78
)
89

910
//check httpServer
@@ -48,10 +49,10 @@ func TestSesionConfig(t *testing.T) {
4849

4950
test.NotNil(t, sessionManager)
5051
test.Equal(t, server.sessionManager.CookieName, session.DefaultSessionCookieName)
51-
test.Equal(t, server.sessionManager.GCLifetime, session.DefaultSessionGCLifeTime)
52+
test.Equal(t, server.sessionManager.GCLifetime, int64(session.DefaultSessionGCLifeTime))
5253
}
5354

54-
//这个用例报错,不知道怎么处理。- -
55+
//
5556
func TestWrapRouterHandle(t *testing.T) {
5657
param := &InitContextParam{
5758
t,
@@ -71,6 +72,23 @@ func TestWrapRouterHandle(t *testing.T) {
7172
handle(context.response.writer, context.request.Request, &ValueNode{})
7273
}
7374

75+
func TestLogRequest(t *testing.T) {
76+
param := &InitContextParam{
77+
t,
78+
"",
79+
"",
80+
test.ToDefault,
81+
}
82+
83+
context := initAllContext(param)
84+
85+
log:=logContext(context,time.Now().Unix())
86+
t.Log("logContext:",log)
87+
//test.NotNil(t,log)
88+
test.Equal(t,"","")
89+
}
90+
91+
7492
func Index(ctx Context) error {
7593
ctx.Response().Header().Set("Content-Type", "text/html; charset=utf-8")
7694
_, err := ctx.WriteStringC(201, "index => ", ctx.RemoteIP(), "我是首页")

‎test/assert.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func Equal(t *testing.T, expected, actual interface{}) {
1717
}
1818

1919
func NotEqual(t *testing.T, expected, actual interface{}) {
20-
if !reflect.DeepEqual(expected, actual) {
20+
if reflect.DeepEqual(expected, actual) {
2121
_, file, line, _ := runtime.Caller(1)
2222
t.Logf("\033[31m%s:%d:\n\n\tvalue should not equal %#v\033[39m\n\n",
2323
filepath.Base(file), line, actual)

0 commit comments

Comments
 (0)