39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package handler
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func TestPhaseOneAndLegacyRoutesAreRegistered(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
router := gin.New()
|
|
NewHandler().RegisterRoutes(router)
|
|
|
|
registered := make(map[string]bool)
|
|
for _, route := range router.Routes() {
|
|
registered[route.Method+" "+route.Path] = true
|
|
}
|
|
want := []string{
|
|
"GET /api/material-categories", "POST /api/material-categories", "PUT /api/material-categories/:id",
|
|
"GET /api/units", "POST /api/units", "PUT /api/units/:id",
|
|
"GET /api/code-rules", "POST /api/code-rules", "PUT /api/code-rules/:id",
|
|
"GET /api/organizations", "GET /api/roles",
|
|
"PUT /api/roles/:id", "GET /api/permissions",
|
|
"GET /api/partners", "POST /api/partners", "PUT /api/partners/:id",
|
|
"GET /api/warehouses", "POST /api/warehouses/:id/locations",
|
|
"POST /api/materials/:id/obsolete", "POST /api/materials/:id/restore",
|
|
"PUT /api/stock/:materialId/warning", "GET /api/stock/:materialId/details",
|
|
"POST /api/applications", "GET /api/logs",
|
|
}
|
|
for _, route := range want {
|
|
if !registered[route] {
|
|
t.Errorf("route not registered: %s", route)
|
|
}
|
|
}
|
|
if registered["DELETE /api/materials/:id"] {
|
|
t.Error("hard-delete material route must not be exposed")
|
|
}
|
|
}
|