mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 18:37:05 +00:00
add an example (and a test case) for same route path pattern but different macro function's input argument
Former-commit-id: f20ac838a08473b6b8114b407cb0dcde7765f634
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/kataras/iris/v12/core/memstore"
|
||||
"github.com/kataras/iris/v12/httptest"
|
||||
)
|
||||
|
||||
func TestSameParameterTypeDifferentMacroFunctions(t *testing.T) {
|
||||
app := newApp()
|
||||
e := httptest.New(t, app)
|
||||
|
||||
type resp struct {
|
||||
Handler string `json:"handler"`
|
||||
Params memstore.Store `json:"params"`
|
||||
}
|
||||
|
||||
var (
|
||||
expectedIndex = resp{
|
||||
Handler: "iris/_examples/routing/dynamic-path/same-pattern-different-func.handler1",
|
||||
Params: nil,
|
||||
}
|
||||
expectedHTMLPage = resp{
|
||||
Handler: "iris/_examples/routing/dynamic-path/same-pattern-different-func.handler1",
|
||||
Params: memstore.Store{
|
||||
{Key: "page", ValueRaw: "random.html"},
|
||||
},
|
||||
}
|
||||
expectedZipName = resp{
|
||||
Handler: "iris/_examples/routing/dynamic-path/same-pattern-different-func.handler2",
|
||||
Params: memstore.Store{
|
||||
{Key: "name", ValueRaw: "random.zip"},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
e.GET("/").Expect().Status(httptest.StatusOK).JSON().Equal(expectedIndex)
|
||||
e.GET("/api/random.html").Expect().Status(httptest.StatusOK).JSON().Equal(expectedHTMLPage)
|
||||
e.GET("/api/random.zip").Expect().Status(httptest.StatusOK).JSON().Equal(expectedZipName)
|
||||
}
|
||||
Reference in New Issue
Block a user