-
Notifications
You must be signed in to change notification settings - Fork 19
/
doc_test.go
52 lines (40 loc) · 857 Bytes
/
doc_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
package crate_test
import (
"database/sql"
"fmt"
_ "github.com/herenow/go-crate"
"testing"
)
func TestExampleCrateDrive_Open(t *testing.T) {
_, err := sql.Open("crate", "http://localhost:4200")
if err != nil {
t.Fatal(err)
}
}
func TestExampleCrateDrive_OpenUsernamePassword(t *testing.T) {
_, err := sql.Open("crate", "http://username:password@localhost:4200")
if err != nil {
t.Fatal(err)
}
}
func TestExampleCrateDriver_Query(t *testing.T) {
db, err := sql.Open("crate", "http://localhost:4200")
if err != nil {
t.Fatal(err)
}
rows, err := db.Query("SELECT name FROM sys.cluster")
if err != nil {
t.Fatal(err)
}
defer rows.Close()
for rows.Next() {
var name string
if err := rows.Scan(&name); err != nil {
t.Fatal(err)
}
fmt.Printf("%s\n", name)
}
if err := rows.Err(); err != nil {
t.Fatal(err)
}
}