57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package router
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func TestAiMateH5CompatibilityRoutes(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
engine := gin.New()
|
|
aiMateRouter(engine.Group("/api/app"))
|
|
|
|
routes := make(map[string]struct{})
|
|
for _, route := range engine.Routes() {
|
|
routes[route.Method+" "+route.Path] = struct{}{}
|
|
}
|
|
expected := []string{
|
|
"GET /api/app/aimate/login",
|
|
"GET /api/app/aimate/getBalance",
|
|
"GET /api/app/aimate/gianBalance",
|
|
"GET /api/app/aimate/currencys",
|
|
"POST /api/app/aimate/exchange",
|
|
}
|
|
for _, route := range expected {
|
|
if _, ok := routes[route]; !ok {
|
|
t.Errorf("route %q is not registered", route)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestAiMateV2Route(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
engine := gin.New()
|
|
aiMateV2Router(engine.Group("/api/app"))
|
|
|
|
for _, route := range engine.Routes() {
|
|
if route.Method == "POST" && route.Path == "/api/app/aimatev2/url" {
|
|
return
|
|
}
|
|
}
|
|
t.Fatal("POST /api/app/aimatev2/url is not registered")
|
|
}
|
|
|
|
func TestContentUpdateMarkerRoute(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
engine := gin.New()
|
|
contentMarkerRouter(engine.Group("/api/app"))
|
|
|
|
for _, route := range engine.Routes() {
|
|
if route.Method == "GET" && route.Path == "/api/app/content/update-markers" {
|
|
return
|
|
}
|
|
}
|
|
t.Fatal("GET /api/app/content/update-markers is not registered")
|
|
}
|