forked from patrickxb/fgosqlite
-
Notifications
You must be signed in to change notification settings - Fork 12
/
config_test.go
73 lines (64 loc) · 1.67 KB
/
config_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright 2010 The Go 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 sqlite_test
import (
"fmt"
"testing"
"github.com/bmizerany/assert"
. "github.com/gwenn/gosqlite"
)
func init() {
err := ConfigThreadingMode(Serialized)
if err != nil {
panic(fmt.Sprintf("cannot change threading mode: '%s'", err))
}
err = ConfigMemStatus(true)
if err != nil {
panic(fmt.Sprintf("cannot activate mem status: '%s'", err))
}
err = ConfigURI(true)
if err != nil {
panic(fmt.Sprintf("cannot activate uri handling: '%s'", err))
}
}
func TestEnableFKey(t *testing.T) {
db := open(t)
defer checkClose(db, t)
b, err := db.IsFKeyEnabled()
checkNoError(t, err, "%s")
if !b {
b, err = db.EnableFKey(true)
checkNoError(t, err, "%s")
assert.T(t, b, "cannot enable FK")
}
}
func TestEnableTriggers(t *testing.T) {
db := open(t)
defer checkClose(db, t)
_, err := db.AreTriggersEnabled()
checkNoError(t, err, "%s")
//if !b {
b, err := db.EnableTriggers(true)
checkNoError(t, err, "%s")
assert.T(t, b, "cannot enable triggers")
//}
}
func TestEnableExtendedResultCodes(t *testing.T) {
db := open(t)
defer checkClose(db, t)
checkNoError(t, db.EnableExtendedResultCodes(true), "cannot enable extended result codes: %s")
}
func TestConnSettings(t *testing.T) {
db := open(t)
defer checkClose(db, t)
err := db.SetRecursiveTriggers("main", true)
checkNoError(t, err, "SetRecursiveTriggers error: %s")
}
func TestCompileOptionUsed(t *testing.T) {
b := CompileOptionUsed("SQLITE_ENABLE_COLUMN_METADATA")
if !b {
t.Log("COLUMN_METADATA disabled")
}
//assert.T(t, b, "COLUMN_METADATA disabled")
}