|
|
- package container
-
- import (
- "github.com/go-xorm/xorm"
- "testing"
- )
-
- func TestTransactionHandlerFactory_New(t *testing.T) {
-
- engine := &xorm.Engine{}
- transactionHandlerFactory := NewTransactionHandlerFactory(engine)
- if transactionHandlerFactory == nil {
- t.Fatalf("创建失败!")
- }
- defaultTransactionHandlerFactory, ok := transactionHandlerFactory.(*DefaultTransactionHandlerFactory)
- if !ok {
- t.Fatalf("会话管理器类型不正确!")
- }
- if defaultTransactionHandlerFactory.engine != engine {
- t.Fatalf("xorm.Engine设置错误!")
- }
- }
-
- func TestTransactionHandlerFactory_New_NullEngine(t *testing.T) {
- defer func() {
- if err := recover(); err != "xorm.Engine不能为空!" {
- t.Fatalf("意外错误:%s", err)
- }
- }()
-
- _ = NewTransactionHandlerFactory(nil)
- t.Fatalf("意外的没有错误!")
- }
|