-
Notifications
You must be signed in to change notification settings - Fork 0
/
conn_test.go
43 lines (34 loc) · 1.01 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
package clickhouse
import (
"errors"
"github.com/stretchr/testify/assert"
"testing"
)
func TestConnect(t *testing.T) {
var conn *Conn
tr := getMockTransport("Ok.")
conn = NewConn("host.local", tr)
assert.Equal(t, "http://host.local/", conn.Host)
conn = NewConn("http://host.local/", tr)
assert.Equal(t, "http://host.local/", conn.Host)
conn = NewConn("https://host.local/", tr)
assert.Equal(t, "https://host.local/", conn.Host)
conn = NewConn("http:/host.local", tr)
assert.Equal(t, "http://http:/host.local/", conn.Host)
}
func TestConn_Ping(t *testing.T) {
tr := getMockTransport("Ok.")
conn := NewConn("host.local", tr)
assert.NoError(t, conn.Ping())
}
func TestConn_Ping2(t *testing.T) {
tr := getMockTransport("")
conn := NewConn("host.local", tr)
assert.Error(t, conn.Ping())
}
func TestConn_Ping3(t *testing.T) {
tr := badTransport{err: errors.New("Connection timeout")}
conn := NewConn("host.local", tr)
assert.Error(t, conn.Ping())
assert.Equal(t, "Connection timeout", conn.Ping().Error())
}