mirror of
https://gitee.com/johng/gf
synced 2026-07-06 05:42:20 +08:00
fix UT cases for package ghttp
This commit is contained in:
@ -58,7 +58,7 @@ func Test_Params_Json_Request(t *testing.T) {
|
||||
t.Assert(client.GetContent(ctx, "/get", `{"id":1,"name":"john","password1":"123Abc!@#","password2":"123Abc!@#"}`), ``)
|
||||
t.Assert(client.GetContent(ctx, "/map", `{"id":1,"name":"john","password1":"123Abc!@#","password2":"123Abc!@#"}`), ``)
|
||||
t.Assert(client.PostContent(ctx, "/parse", `{"id":1,"name":"john","password1":"123Abc!@#","password2":"123Abc!@#"}`), `1john123Abc!@#123Abc!@#`)
|
||||
t.Assert(client.PostContent(ctx, "/parse", `{"id":1,"name":"john","password1":"123Abc!@#","password2":"123"}`), `密码强度不足; 两次密码不一致`)
|
||||
t.Assert(client.PostContent(ctx, "/parse", `{"id":1,"name":"john","password1":"123Abc!@#","password2":"123"}`), `密码强度不足`)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -453,7 +453,7 @@ func Test_Params_Struct(t *testing.T) {
|
||||
t.Assert(client.PostContent(ctx, "/struct2", `id=1&name=john&password1=123&password2=456`), `1john123456`)
|
||||
t.Assert(client.PostContent(ctx, "/struct2", ``), ``)
|
||||
t.Assert(client.PostContent(ctx, "/struct-valid", `id=1&name=john&password1=123&password2=0`), "The password2 value `0` length must be between 2 and 20; 密码强度不足")
|
||||
t.Assert(client.PostContent(ctx, "/parse", `id=1&name=john&password1=123&password2=0`), "The password2 value `0` length must be between 2 and 20; 密码强度不足")
|
||||
t.Assert(client.PostContent(ctx, "/parse", `id=1&name=john&password1=123&password2=0`), "The password2 value `0` length must be between 2 and 20")
|
||||
t.Assert(client.PostContent(ctx, "/parse", `{"id":1,"name":"john","password1":"123Abc!@#","password2":"123Abc!@#"}`), `1john123Abc!@#123Abc!@#`)
|
||||
})
|
||||
}
|
||||
|
||||
@ -564,8 +564,8 @@ func Test_Params_Parse_Validation(t *testing.T) {
|
||||
client := g.Client()
|
||||
client.SetPrefix(prefix)
|
||||
|
||||
t.Assert(client.GetContent(ctx, "/parse"), `请输入账号; 账号长度为6到30位; 请输入密码; 密码长度不够; 请确认密码; 密码长度不够; 两次密码不一致`)
|
||||
t.Assert(client.GetContent(ctx, "/parse?name=john11&password1=123456&password2=123"), `密码长度不够; 两次密码不一致`)
|
||||
t.Assert(client.GetContent(ctx, "/parse"), `请输入账号`)
|
||||
t.Assert(client.GetContent(ctx, "/parse?name=john11&password1=123456&password2=123"), `密码长度不够`)
|
||||
t.Assert(client.GetContent(ctx, "/parse?name=john&password1=123456&password2=123456"), `账号长度为6到30位`)
|
||||
t.Assert(client.GetContent(ctx, "/parse?name=john11&password1=123456&password2=123456"), `ok`)
|
||||
})
|
||||
|
||||
@ -61,6 +61,6 @@ func Test_Params_Xml_Request(t *testing.T) {
|
||||
t.Assert(client.GetContent(ctx, "/map", content1), ``)
|
||||
t.Assert(client.PostContent(ctx, "/map", content1), `1john123Abc!@#123Abc!@#`)
|
||||
t.Assert(client.PostContent(ctx, "/parse", content1), `1john123Abc!@#123Abc!@#`)
|
||||
t.Assert(client.PostContent(ctx, "/parse", content2), `密码强度不足; 两次密码不一致`)
|
||||
t.Assert(client.PostContent(ctx, "/parse", content2), `密码强度不足`)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user