iris/_examples/routing/dynamic-path/same-pattern-different-func/main_test.go
Gerasimos (Makis) Maropoulos 6add1ba49b
fix #2158 and more
2023-07-08 02:08:18 +03:00

42 lines
1.1 KiB
Go

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().IsEqual(expectedIndex)
e.GET("/api/random.html").Expect().Status(httptest.StatusOK).JSON().IsEqual(expectedHTMLPage)
e.GET("/api/random.zip").Expect().Status(httptest.StatusOK).JSON().IsEqual(expectedZipName)
}