initial support for path param
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
30
http_test.go
Normal file
30
http_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
Name string `json:"name"`
|
||||
Field1 string
|
||||
Field2 string
|
||||
Field3 int64
|
||||
}
|
||||
|
||||
func TestValidPath(t *testing.T) {
|
||||
req := &Request{Name: "vtolstov", Field1: "field1", Field2: "field2", Field3: 10}
|
||||
p, m, err := newPathRequest("/api/v1/{name}/list", "GET", "", req)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, _ = p, m
|
||||
}
|
||||
|
||||
func TestInvalidPath(t *testing.T) {
|
||||
req := &Request{Name: "vtolstov", Field1: "field1", Field2: "field2", Field3: 10}
|
||||
p, m, err := newPathRequest("/api/v1/{xname}/list", "GET", "", req)
|
||||
if err == nil {
|
||||
t.Fatalf("path param must not be filled")
|
||||
}
|
||||
_, _ = p, m
|
||||
}
|
Reference in New Issue
Block a user