@@ -44,6 +44,11 @@ func PrepareServerAndClient(t *testing.T, config TestConfig, logRequests bool, o
4444 cloudEnv := os .Getenv ("CLOUD_ENV" )
4545 recordRequests := isTruePtr (config .RecordRequests )
4646
47+ // Use a unique token for each test. This allows us to maintain
48+ // separate state for each test in fake workspaces.
49+ tokenSuffix := strings .ReplaceAll (uuid .NewString (), "-" , "" )
50+ token := "dbapi" + tokenSuffix
51+
4752 if cloudEnv != "" {
4853 w , err := databricks .NewWorkspaceClient ()
4954 require .NoError (t , err )
@@ -56,7 +61,7 @@ func PrepareServerAndClient(t *testing.T, config TestConfig, logRequests bool, o
5661 // If we are running in a cloud environment AND we are recording requests,
5762 // start a dedicated server to act as a reverse proxy to a real Databricks workspace.
5863 if recordRequests {
59- host , token := startProxyServer (t , logRequests , config .IncludeRequestHeaders , outputDir )
64+ host := startProxyServer (t , logRequests , config .IncludeRequestHeaders , outputDir )
6065 cfg = & sdkconfig.Config {
6166 Host : host ,
6267 Token : token ,
@@ -69,11 +74,6 @@ func PrepareServerAndClient(t *testing.T, config TestConfig, logRequests bool, o
6974 // If we are not recording requests, and no custom server stubs are configured,
7075 // use the default shared server.
7176 if len (config .Server ) == 0 && ! recordRequests {
72- // Use a unique token for each test. This allows us to maintain
73- // separate state for each test in fake workspaces.
74- tokenSuffix := strings .ReplaceAll (uuid .NewString (), "-" , "" )
75- token := "dbapi" + tokenSuffix
76-
7777 cfg := & sdkconfig.Config {
7878 Host : os .Getenv ("DATABRICKS_DEFAULT_HOST" ),
7979 Token : token ,
@@ -84,7 +84,7 @@ func PrepareServerAndClient(t *testing.T, config TestConfig, logRequests bool, o
8484
8585 // Default case. Start a dedicated local server for the test with the server stubs configured
8686 // as overrides.
87- host , token := startLocalServer (t , config .Server , recordRequests , logRequests , config .IncludeRequestHeaders , outputDir )
87+ host := startLocalServer (t , config .Server , recordRequests , logRequests , config .IncludeRequestHeaders , outputDir )
8888 cfg := & sdkconfig.Config {
8989 Host : host ,
9090 Token : token ,
@@ -137,7 +137,7 @@ func startLocalServer(t *testing.T,
137137 logRequests bool ,
138138 includeHeaders []string ,
139139 outputDir string ,
140- ) ( string , string ) {
140+ ) string {
141141 s := testserver .New (t )
142142
143143 // Record API requests in out.requests.txt if RecordRequests is true
@@ -166,14 +166,14 @@ func startLocalServer(t *testing.T,
166166
167167 // The earliest handlers take precedence, add default handlers last
168168 addDefaultHandlers (s )
169- return s .URL , "dbapi123"
169+ return s .URL
170170}
171171
172172func startProxyServer (t * testing.T ,
173173 logRequests bool ,
174174 includeHeaders []string ,
175175 outputDir string ,
176- ) ( string , string ) {
176+ ) string {
177177 s := testproxy .New (t )
178178
179179 // Always record requests for a proxy server.
@@ -184,7 +184,7 @@ func startProxyServer(t *testing.T,
184184 s .ResponseCallback = logResponseCallback (t )
185185 }
186186
187- return s .URL , "dbapi1234"
187+ return s .URL
188188}
189189
190190type LoggedRequest struct {
0 commit comments