forked from exasol/exasol-driver-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver_test.go
89 lines (74 loc) · 2.8 KB
/
driver_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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package exasol
import (
"testing"
"github.com/stretchr/testify/suite"
)
type DriverTestSuite struct {
suite.Suite
}
func TestDriverSuite(t *testing.T) {
suite.Run(t, new(DriverTestSuite))
}
func (suite *DriverTestSuite) TestOpenConnector() {
exasolDriver := ExasolDriver{}
conn, err := exasolDriver.OpenConnector("exa:localhost:1234")
suite.NoError(err)
suite.NotNil(conn)
}
func (suite *DriverTestSuite) TestOpenConnectorBadDsn() {
exasolDriver := ExasolDriver{}
conn, err := exasolDriver.OpenConnector("")
suite.EqualError(err, "E-EGOD-21: invalid connection string, must start with 'exa:': ''")
suite.Nil(conn)
}
func (suite *DriverTestSuite) TestOpen() {
exasolDriver := ExasolDriver{}
conn, err := exasolDriver.Open("exa:localhost:1234")
suite.ErrorContains(err, "connection refused")
suite.Nil(conn)
}
func (suite *DriverTestSuite) TestOpenBadDsn() {
exasolDriver := ExasolDriver{}
conn, err := exasolDriver.Open("")
suite.EqualError(err, "E-EGOD-21: invalid connection string, must start with 'exa:': ''")
suite.Nil(conn)
}
func (suite *DriverTestSuite) TestConfigToDsnWithBooleanValuesTrue() {
config := NewConfig("sys", "exasol").
Compression(true).
Encryption(true).
Autocommit(true).
ValidateServerCertificate(true)
suite.Equal("exa:localhost:8563;user=sys;password=exasol;autocommit=1;compression=1;encryption=1;validateservercertificate=1", config.String())
}
func (suite *DriverTestSuite) TestConfigToDsnWithBooleanValuesFalse() {
config := NewConfig("sys", "exasol").
Compression(false).
Encryption(false).
Autocommit(false).
ValidateServerCertificate(false)
suite.Equal("exa:localhost:8563;user=sys;password=exasol;autocommit=0;compression=0;encryption=0;validateservercertificate=0", config.String())
}
func (suite *DriverTestSuite) TestConfigToDsnWithClientNameAndVersion() {
config := NewConfig("sys", "exasol").
ClientName("clientName").
ClientVersion("clientVersion")
suite.Equal("exa:localhost:8563;user=sys;password=exasol;clientname=clientName;clientversion=clientVersion", config.String())
}
func (suite *DriverTestSuite) TestConfigToDsnWithSchema() {
config := NewConfig("sys", "exasol").
Schema("schemaName")
suite.Equal("exa:localhost:8563;user=sys;password=exasol;schema=schemaName", config.String())
}
func (suite *DriverTestSuite) TestConfigToDsnWithDefaultValues() {
config := NewConfig("sys", "exasol")
suite.Equal("exa:localhost:8563;user=sys;password=exasol", config.String())
}
func (suite *DriverTestSuite) TestConfigWithAccessToken() {
config := NewConfigWithAccessToken("TOKEN.JWT.TEST")
suite.Equal("exa:localhost:8563;accesstoken=TOKEN.JWT.TEST", config.String())
}
func (suite *DriverTestSuite) TestConfigWithrefreshToken() {
config := NewConfigWithRefreshToken("RefreshToken")
suite.Equal("exa:localhost:8563;refreshtoken=RefreshToken", config.String())
}