feat: standardize REST and RPC routes
This commit is contained in:
34
module/base/fts/internal/routers/register_test.go
Normal file
34
module/base/fts/internal/routers/register_test.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package routers
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func TestRoutesUseRESTModulePrefix(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
engine := gin.New()
|
||||
Register("fts", engine)
|
||||
|
||||
expected := map[string]bool{
|
||||
"GET /rest/fts/v1/ping": false,
|
||||
"GET /rest/fts/v1/config": false,
|
||||
"POST /rest/fts/v1/uploader": false,
|
||||
}
|
||||
for _, route := range engine.Routes() {
|
||||
key := route.Method + " " + route.Path
|
||||
if _, ok := expected[key]; ok {
|
||||
expected[key] = true
|
||||
}
|
||||
if strings.HasPrefix(route.Path, "/fts/") {
|
||||
t.Fatalf("legacy route remains registered: %s", route.Path)
|
||||
}
|
||||
}
|
||||
for route, found := range expected {
|
||||
if !found {
|
||||
t.Errorf("route not registered: %s", route)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user