forked from latolukasz/beeorm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathengine_test.go
49 lines (43 loc) · 1.34 KB
/
engine_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package beeorm
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestEngine(t *testing.T) {
engine, def := prepareTables(t, &Registry{}, 5, "", "2.0")
defer def()
source := engine.GetRegistry().GetSourceRegistry()
assert.NotNil(t, source)
assert.PanicsWithError(t, "unregistered mysql pool 'test'", func() {
engine.GetMysql("test")
})
assert.PanicsWithError(t, "unregistered local cache pool 'test'", func() {
engine.GetLocalCache("test")
})
assert.PanicsWithError(t, "unregistered redis cache pool 'test'", func() {
engine.GetRedis("test")
})
engine.EnableQueryDebug()
assert.Len(t, engine.queryLoggersRedis, 1)
assert.Len(t, engine.queryLoggersDB, 1)
assert.Len(t, engine.queryLoggersLocalCache, 1)
engine.EnableQueryDebugCustom(true, true, false)
assert.Len(t, engine.queryLoggersRedis, 1)
assert.Len(t, engine.queryLoggersDB, 1)
assert.Len(t, engine.queryLoggersLocalCache, 1)
engine2 := engine.Clone().(*engineImplementation)
assert.NotNil(t, engine2)
assert.Len(t, engine2.queryLoggersRedis, 1)
assert.Len(t, engine2.queryLoggersDB, 1)
assert.Len(t, engine2.queryLoggersLocalCache, 1)
}
func BenchmarkEngine(b *testing.B) {
registry := &Registry{}
validatedRegistry, def, _ := registry.Validate()
defer def()
b.ResetTimer()
b.ReportAllocs()
for n := 0; n < b.N; n++ {
validatedRegistry.CreateEngine()
}
}