Files
xuanzhi-service/server/utils/validator_test.go
wdh-home 05ee541420
Some checks failed
CI / init (push) Has been cancelled
CI / Frontend node 18.16.0 (push) Has been cancelled
CI / Backend go (1.22) (push) Has been cancelled
CI / devops-test (1.22, 18.16.0) (push) Has been cancelled
CI / release-pr (push) Has been cancelled
CI / release-please (push) Has been cancelled
CI / devops-prod (1.22, 18.x) (push) Has been cancelled
CI / docker (push) Has been cancelled
init
2026-04-21 16:50:31 +08:00

38 lines
925 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package utils
import (
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
"testing"
)
type PageInfoTest struct {
PageInfo request.PageInfo
Name string
}
func TestVerify(t *testing.T) {
PageInfoVerify := Rules{"Page": {NotEmpty()}, "PageSize": {NotEmpty()}, "Name": {NotEmpty()}}
var testInfo PageInfoTest
testInfo.Name = "test"
testInfo.PageInfo.Page = 0
testInfo.PageInfo.PageSize = 0
err := Verify(testInfo, PageInfoVerify)
if err == nil {
t.Error("校验失败未能捕捉0值")
}
testInfo.Name = ""
testInfo.PageInfo.Page = 1
testInfo.PageInfo.PageSize = 10
err = Verify(testInfo, PageInfoVerify)
if err == nil {
t.Error("校验失败未能正常检测name为空")
}
testInfo.Name = "test"
testInfo.PageInfo.Page = 1
testInfo.PageInfo.PageSize = 10
err = Verify(testInfo, PageInfoVerify)
if err != nil {
t.Error("校验失败,未能正常通过检测")
}
}