allow register mock

This commit is contained in:
Ming Deng 2021-04-14 23:13:11 +08:00
parent 641a791265
commit 452dae86be
5 changed files with 6 additions and 8 deletions

View File

@ -1,5 +1,5 @@
# developing
- Web mock and test support. [4565](https://github.com/beego/beego/pull/4565)
- Web mock and test support. [4565](https://github.com/beego/beego/pull/4565) [4574](https://github.com/beego/beego/pull/4574)
- Error codes definition of cache module. [4493](https://github.com/beego/beego/pull/4493)
- Remove generateCommentRoute http hook. Using `bee generate routers` commands instead.[4486](https://github.com/beego/beego/pull/4486) [bee PR 762](https://github.com/beego/bee/pull/762)
- Fix: /abc.html/aaa match /abc/aaa. [4459](https://github.com/beego/beego/pull/4459)

View File

@ -521,7 +521,7 @@ func init() {
err := InitGlobalInstance("ini", "conf/app.conf")
if err != nil {
logs.Warn("init global config instance failed. If you donot use this, just ignore it. ", err)
logs.Debug("init global config instance failed. If you donot use this, just ignore it. ", err)
}
}

View File

@ -54,7 +54,7 @@ func (c *TestController) HelloSession() {
c.Ctx.WriteString("error")
return
}
c.SetSession("name", "Tom")
_ = c.SetSession("name", "Tom")
c.Ctx.WriteString("set")
}

View File

@ -77,6 +77,7 @@ func (s *SessionProvider) SessionAll(ctx context.Context) int {
// SessionGC do nothing
func (s *SessionProvider) SessionGC(ctx context.Context) {
// we do anything since we don't need to mock GC
}
@ -105,6 +106,7 @@ func (s *SessionStore) SessionID(ctx context.Context) string {
// SessionRelease do nothing
func (s *SessionStore) SessionRelease(ctx context.Context, w http.ResponseWriter) {
// Support in the future if necessary, now I think we don't need to implement this
}
func (s *SessionStore) Flush(ctx context.Context) error {

View File

@ -70,15 +70,11 @@ var provides = make(map[string]Provider)
var SLogger = NewSessionLog(os.Stderr)
// Register makes a session provide available by the provided name.
// If Register is called twice with the same name or if driver is nil,
// it panics.
// If provider is nil, it panic
func Register(name string, provide Provider) {
if provide == nil {
panic("session: Register provide is nil")
}
if _, dup := provides[name]; dup {
panic("session: Register called twice for provider " + name)
}
provides[name] = provide
}