update tests

This commit is contained in:
Nurzhan Ilyassov 2024-03-26 12:44:45 +05:00 committed by Vasiliy Tolstov
parent 4c2178305d
commit fd803b1fe0

View File

@ -61,24 +61,32 @@ func TestNewPathRequest(t *testing.T) {
func TestNewPathRequestWithEmptyBody(t *testing.T) { func TestNewPathRequestWithEmptyBody(t *testing.T) {
val := struct{}{} val := struct{}{}
cases := []string{
"",
"*",
"{}",
"nil",
`{"type": "invalid"}`,
}
for _, m := range []string{"POST", "PUT", "PATCH", "GET", "DELETE"} { for _, body := range cases {
body := `{"type": "invalid"}` for _, m := range []string{"POST", "PUT", "PATCH", "GET", "DELETE"} {
path, nmsg, err := newPathRequest("/v1/test", m, body, val, []string{"protobuf", "json"}, nil) path, nmsg, err := newPathRequest("/v1/test", m, body, val, []string{"protobuf", "json"}, nil)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if nmsg == nil { if nmsg == nil {
t.Fatalf("invalid path: nil nmsg") t.Fatalf("invalid path: nil nmsg")
} }
u, err := url.Parse(path) u, err := url.Parse(path)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
vals := u.Query() vals := u.Query()
if len(vals) != 0 { if len(vals) != 0 {
t.Fatalf("invalid path: %v nmsg: %v", path, nmsg) t.Fatalf("invalid path: %v nmsg: %v", path, nmsg)
}
} }
} }
} }