hertz101/app/facade/biz/handler/facade/facade_service_test.go
2025-01-20 21:45:01 +08:00

41 lines
1.4 KiB
Go

package facade
import (
"bytes"
"testing"
"github.com/cloudwego/hertz/pkg/app/server"
//"github.com/cloudwego/hertz/pkg/common/test/assert"
"github.com/cloudwego/hertz/pkg/common/ut"
)
func TestRegister(t *testing.T) {
h := server.Default()
h.POST("/register", Register)
path := "/register" // todo: you can customize query
body := &ut.Body{Body: bytes.NewBufferString(""), Len: 1} // todo: you can customize body
header := ut.Header{} // todo: you can customize header
w := ut.PerformRequest(h.Engine, "POST", path, body, header)
resp := w.Result()
t.Log(string(resp.Body()))
// todo edit your unit test.
// assert.DeepEqual(t, 200, resp.StatusCode())
// assert.DeepEqual(t, "null", string(resp.Body()))
}
func TestLogin(t *testing.T) {
h := server.Default()
h.POST("/login", Login)
path := "/login" // todo: you can customize query
body := &ut.Body{Body: bytes.NewBufferString(""), Len: 1} // todo: you can customize body
header := ut.Header{} // todo: you can customize header
w := ut.PerformRequest(h.Engine, "POST", path, body, header)
resp := w.Result()
t.Log(string(resp.Body()))
// todo edit your unit test.
// assert.DeepEqual(t, 200, resp.StatusCode())
// assert.DeepEqual(t, "null", string(resp.Body()))
}