26 lines
760 B
Go
26 lines
760 B
Go
// Package routers 测试受鉴权上传端点的路由注册。
|
||
// 版本:v1.0.0
|
||
package routers
|
||
|
||
import (
|
||
"net/http"
|
||
"testing"
|
||
|
||
"github.com/gin-gonic/gin"
|
||
)
|
||
|
||
// TestUploadRoutesExposeDedicatedAvatarEndpoint 验证专用头像上传路由已注册且不改变原文件上传路由。
|
||
func TestUploadRoutesExposeDedicatedAvatarEndpoint(t *testing.T) {
|
||
engine := gin.New()
|
||
registerUploadRoute("heqi", engine)
|
||
routes := make(map[string]map[string]bool)
|
||
for _, route := range engine.Routes() {
|
||
if routes[route.Path] == nil {
|
||
routes[route.Path] = make(map[string]bool)
|
||
}
|
||
routes[route.Path][route.Method] = true
|
||
}
|
||
assertRouteMethods(t, routes, "/upload/file", http.MethodPost)
|
||
assertRouteMethods(t, routes, "/upload/avatar", http.MethodPost)
|
||
}
|