forked from go-xorm/xorm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsession_test.go
56 lines (43 loc) · 1.17 KB
/
session_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
50
51
52
53
54
55
56
// Copyright 2017 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.
package xorm
import (
"database/sql"
"testing"
"github.com/stretchr/testify/assert"
)
func TestClose(t *testing.T) {
assert.NoError(t, prepareEngine())
sess1 := testEngine.NewSession()
sess1.Close()
assert.True(t, sess1.IsClosed())
sess2 := testEngine.Where("a = ?", 1)
sess2.Close()
assert.True(t, sess2.IsClosed())
}
func TestNullFloatStruct(t *testing.T) {
type MyNullFloat64 sql.NullFloat64
type MyNullFloatStruct struct {
Uuid string
Amount MyNullFloat64
}
assert.NoError(t, prepareEngine())
assert.NoError(t, testEngine.Sync2(new(MyNullFloatStruct)))
_, err := testEngine.Insert(&MyNullFloatStruct{
Uuid: "111111",
Amount: MyNullFloat64(sql.NullFloat64{
Float64: 0.1111,
Valid: true,
}),
})
assert.NoError(t, err)
}
func TestMustLogSQL(t *testing.T) {
assert.NoError(t, prepareEngine())
testEngine.ShowSQL(false)
defer testEngine.ShowSQL(true)
assertSync(t, new(Userinfo))
_, err := testEngine.Table("userinfo").MustLogSQL(true).Get(new(Userinfo))
assert.NoError(t, err)
}