You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
510 B
25 lines
510 B
package middleware
|
|
|
|
import (
|
|
"cloudreve/pkg/util"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// SessionMock 测试时模拟Session
|
|
var SessionMock = make(map[string]interface{})
|
|
|
|
// ContextMock 测试时模拟Context
|
|
var ContextMock = make(map[string]interface{})
|
|
|
|
// MockHelper 单元测试助手中间件
|
|
func MockHelper() gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
// 将SessionMock写入会话
|
|
util.SetSession(c, SessionMock)
|
|
for key, value := range ContextMock {
|
|
c.Set(key, value)
|
|
}
|
|
c.Next()
|
|
}
|
|
}
|