fix unit testing cases

This commit is contained in:
John Guo
2021-10-21 19:25:39 +08:00
parent fa5499373a
commit 862ef57e0f
5 changed files with 8 additions and 8 deletions

View File

@ -48,8 +48,8 @@ func init() {
Port: "3306",
User: TestDbUser,
Pass: TestDbPass,
Name: parser.GetOpt("name", ""),
Type: parser.GetOpt("type", "mysql"),
Name: parser.GetOpt("name", "").String(),
Type: parser.GetOpt("type", "mysql").String(),
Role: "master",
Charset: "utf8",
Weight: 1,

View File

@ -39,8 +39,8 @@ func init() {
Port: "3306",
User: TestDbUser,
Pass: TestDbPass,
Name: parser.GetOpt("name", ""),
Type: parser.GetOpt("type", "mysql"),
Name: parser.GetOpt("name", "").String(),
Type: parser.GetOpt("type", "mysql").String(),
Role: "master",
Charset: "utf8",
Weight: 1,

View File

@ -61,7 +61,7 @@ func Test_OpenApi_Swagger(t *testing.T) {
c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", p))
t.Assert(c.GetContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Age":18,"Name":"john"}}`)
t.Assert(c.GetContent(ctx, "/test/error"), `{"code":50,"message":"error"}`)
t.Assert(c.GetContent(ctx, "/test/error"), `{"code":50,"message":"error","data":null}`)
t.Assert(gstr.Contains(c.GetContent(ctx, "/swagger/"), `SwaggerUIBundle`), true)
t.Assert(gstr.Contains(c.GetContent(ctx, "/api.json"), `/test/error`), true)

View File

@ -56,6 +56,6 @@ func Test_Router_Handler_Extended_Handler_WithObject(t *testing.T) {
client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", p))
t.Assert(client.GetContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Age":18,"Name":"john"}}`)
t.Assert(client.GetContent(ctx, "/test/error"), `{"code":50,"message":"error"}`)
t.Assert(client.GetContent(ctx, "/test/error"), `{"code":50,"message":"error","data":null}`)
})
}

View File

@ -190,8 +190,8 @@ func ExampleRegisterRule_OverwriteRequired() {
// It's required
// rule deleted
// It's required
// `nil`
// `nil`
// <nil>
// <nil>
}
func ExampleValidator_Rules() {