|
|
- package container
-
- import (
- "github.com/go-xorm/xorm"
- "testing"
- )
-
- func TestDefaultTransactionHandlerFactory_New(t *testing.T) {
-
- engine := &xorm.Engine{}
- defaultTransactionHandlerFactory := NewDefaultTransactionHandlerFactory(engine)
- if defaultTransactionHandlerFactory == nil {
- t.Fatalf("创建失败!")
- }
- if defaultTransactionHandlerFactory.engine != engine {
- t.Fatalf("xorm.Engine设置错误!")
- }
- }
-
- func TestDefaultTransactionHandlerFactory_New_NullEngine(t *testing.T) {
- defer func() {
- if err := recover(); err != "xorm.Engine不能为空!" {
- t.Fatalf("意外错误:%s", err)
- }
- }()
-
- _ = NewDefaultTransactionHandlerFactory(nil)
- t.Fatalf("意外的没有错误!")
- }
|