44 "context"
55 "github.com/databricks/databricks-sql-go/internal/config"
66 "github.com/stretchr/testify/assert"
7+ "github.com/stretchr/testify/require"
78 "testing"
9+ "time"
810)
911
1012func TestConnector_Connect (t * testing.T ) {
@@ -22,44 +24,46 @@ func TestConnector_Connect(t *testing.T) {
2224}
2325
2426func TestNewConnector (t * testing.T ) {
25- //t.Run("Connector initialized with functional options should have all options set", func(t *testing.T) {
26- // host := "databricks-host"
27- // port := 1
28- // accessToken := "token"
29- // httpPath := "http-path"
30- // maxRows := 100
31- // timeout := 100
32- // catalog := "catalog-name"
33- // schema := "schema-string"
34- // userAgentEntry := "user-agent"
35- // sessionParams := map[string]string{"key": "value"}
36- // connector, err := NewConnector(
37- // WithServerHostname(host),
38- // WithPort(port),
39- // WithAccessToken(accessToken),
40- // WithHTTPPath(httpPath),
41- // WithMaxRows(maxRows),
42- // WithTimeout(timeout),
43- // WithInitialNamespace(catalog, schema),
44- // WithUserAgentEntry(userAgentEntry),
45- // WithSessionParams(sessionParams),
46- // )
47- // expectedUserConfig := config.UserConfig{
48- // Host: host,
49- // Port: port,
50- // AccessToken: accessToken,
51- // HTTPPath: httpPath,
52- // MaxRows: maxRows,
53- // QueryTimeoutSeconds: timeout,
54- // Catalog: catalog,
55- // Schema: schema,
56- // UserAgentEntry: userAgentEntry,
57- // SessionParams: sessionParams,
58- // }
59- // expectedCfg := config.WithDefaults()
60- // expectedCfg.UserConfig = expectedUserConfig
61- // resultCfg := connector.cfg // ??? something like this possible ??? this doesn't compile
62- // assert.Nil(t, err)
63- // assert.Equal(t, expectedCfg, resultCfg)
64- //})
27+ t .Run ("Connector initialized with functional options should have all options set" , func (t * testing.T ) {
28+ host := "databricks-host"
29+ port := 1
30+ accessToken := "token"
31+ httpPath := "http-path"
32+ maxRows := 100
33+ timeout := 100 * time .Second
34+ catalog := "catalog-name"
35+ schema := "schema-string"
36+ userAgentEntry := "user-agent"
37+ sessionParams := map [string ]string {"key" : "value" }
38+ con , err := NewConnector (
39+ WithServerHostname (host ),
40+ WithPort (port ),
41+ WithAccessToken (accessToken ),
42+ WithHTTPPath (httpPath ),
43+ WithMaxRows (maxRows ),
44+ WithTimeout (timeout ),
45+ WithInitialNamespace (catalog , schema ),
46+ WithUserAgentEntry (userAgentEntry ),
47+ WithSessionParams (sessionParams ),
48+ )
49+ expectedUserConfig := config.UserConfig {
50+ Host : host ,
51+ Port : port ,
52+ Protocol : "https" ,
53+ AccessToken : accessToken ,
54+ HTTPPath : httpPath ,
55+ MaxRows : maxRows ,
56+ QueryTimeout : timeout ,
57+ Catalog : catalog ,
58+ Schema : schema ,
59+ UserAgentEntry : userAgentEntry ,
60+ SessionParams : sessionParams ,
61+ }
62+ expectedCfg := config .WithDefaults ()
63+ expectedCfg .UserConfig = expectedUserConfig
64+ coni , ok := con .(* connector )
65+ require .True (t , ok )
66+ assert .Nil (t , err )
67+ assert .Equal (t , expectedCfg , coni .cfg )
68+ })
6569}
0 commit comments