-
Notifications
You must be signed in to change notification settings - Fork 41
/
driver_test.go
39 lines (35 loc) · 1.07 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
package dbsql
import (
"fmt"
"testing"
"github.com/databricks/databricks-sql-go/auth/pat"
"github.com/databricks/databricks-sql-go/internal/config"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestOOpenConnector(t *testing.T) {
t.Run("Should work with valid dsn", func(t *testing.T) {
host := "databricks-host"
port := 443
accessToken := "token"
httpPath := "http-path"
expectedUserConfig := config.UserConfig{
Host: host,
Port: port,
Protocol: "https",
AccessToken: accessToken,
HTTPPath: "/" + httpPath,
Authenticator: &pat.PATAuth{AccessToken: accessToken},
}
expectedCfg := config.WithDefaults()
expectedCfg.UserConfig = expectedUserConfig.WithDefaults()
expectedCfg.DriverVersion = DriverVersion
d := &databricksDriver{}
c, err := d.OpenConnector(fmt.Sprintf("token:%s@%s:%d/%s", accessToken, host, port, httpPath))
require.NoError(t, err)
coni, ok := c.(*connector)
require.True(t, ok)
assert.Equal(t, expectedCfg, coni.cfg)
assert.NotNil(t, coni.client)
})
}