2020-03-13 00:42:01 +00:00
|
|
|
// Copyright 2020 The Xorm Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2023-07-26 10:44:41 +00:00
|
|
|
package tests
|
2020-03-13 00:42:01 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-03-27 07:13:04 +00:00
|
|
|
"xorm.io/xorm"
|
2020-03-13 00:42:01 +00:00
|
|
|
"xorm.io/xorm/log"
|
|
|
|
"xorm.io/xorm/schemas"
|
2020-03-27 07:13:04 +00:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-03-13 00:42:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestEngineGroup(t *testing.T) {
|
2020-03-27 07:13:04 +00:00
|
|
|
assert.NoError(t, PrepareEngine())
|
2020-03-13 00:42:01 +00:00
|
|
|
|
2020-03-27 07:13:04 +00:00
|
|
|
master := testEngine.(*xorm.Engine)
|
2020-03-13 00:42:01 +00:00
|
|
|
if master.Dialect().URI().DBType == schemas.SQLITE {
|
|
|
|
t.Skip()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-03-27 07:13:04 +00:00
|
|
|
eg, err := xorm.NewEngineGroup(master, []*xorm.Engine{master})
|
2020-03-13 00:42:01 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
eg.SetMaxIdleConns(10)
|
|
|
|
eg.SetMaxOpenConns(100)
|
|
|
|
eg.SetTableMapper(master.GetTableMapper())
|
|
|
|
eg.SetColumnMapper(master.GetColumnMapper())
|
|
|
|
eg.SetLogLevel(log.LOG_INFO)
|
|
|
|
eg.ShowSQL(true)
|
|
|
|
}
|