-
Notifications
You must be signed in to change notification settings - Fork 36
/
conn_test.go
60 lines (48 loc) · 1.23 KB
/
conn_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
package gorqlite_test
import (
"testing"
"github.com/rqlite/gorqlite"
)
func TestSetConsistencyLevel(t *testing.T) {
conn, err := gorqlite.Open(testUrl())
if err != nil {
t.Fatalf("failed to open connection: %v", err.Error())
}
t.Run("Less than none", func(t *testing.T) {
err := conn.SetConsistencyLevel(-1)
if err == nil {
t.Errorf("expected error, got nil")
}
})
t.Run("Greater than strong", func(t *testing.T) {
err := conn.SetConsistencyLevel(100)
if err == nil {
t.Errorf("expected error, got nil")
}
})
t.Run("None", func(t *testing.T) {
err := conn.SetConsistencyLevel(gorqlite.ConsistencyLevelNone)
if err != nil {
t.Errorf("expected nil, got %v", err)
}
currentLevel, err := conn.ConsistencyLevel()
if err != nil {
t.Errorf("unexpected error: %s", err.Error())
}
if currentLevel != "none" {
t.Errorf("expected currentLevel to be 'none', instead got %s", currentLevel)
}
})
conn.Close()
}
func TestSetExecutionWithTransaction(t *testing.T) {
conn, err := gorqlite.Open(testUrl())
if err != nil {
t.Fatalf("failed to open connection: %v", err.Error())
}
err = conn.SetExecutionWithTransaction(true)
if err != nil {
t.Errorf("expected nil, got %v", err)
}
conn.Close()
}