GAAS GFrame项目web后台
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.

33 lines
815 B

  1. package container
  2. import (
  3. "github.com/go-xorm/xorm"
  4. "testing"
  5. )
  6. func TestTransactionHandlerFactory_New(t *testing.T) {
  7. engine := &xorm.Engine{}
  8. transactionHandlerFactory := NewTransactionHandlerFactory(engine)
  9. if transactionHandlerFactory == nil {
  10. t.Fatalf("创建失败!")
  11. }
  12. defaultTransactionHandlerFactory, ok := transactionHandlerFactory.(*DefaultTransactionHandlerFactory)
  13. if !ok {
  14. t.Fatalf("会话管理器类型不正确!")
  15. }
  16. if defaultTransactionHandlerFactory.engine != engine {
  17. t.Fatalf("xorm.Engine设置错误!")
  18. }
  19. }
  20. func TestTransactionHandlerFactory_New_NullEngine(t *testing.T) {
  21. defer func() {
  22. if err := recover(); err != "xorm.Engine不能为空!" {
  23. t.Fatalf("意外错误:%s", err)
  24. }
  25. }()
  26. _ = NewTransactionHandlerFactory(nil)
  27. t.Fatalf("意外的没有错误!")
  28. }