@@ -131,7 +131,7 @@ class RefreshTokenTest {
131
131
}
132
132
133
133
runWithServer { port ->
134
- val modelClient = ModelClientV2 .builder().url(" http://localhost:$port " ).authConfig(
134
+ ModelClientV2 .builder().url(" http://localhost:$port " ).authConfig(
135
135
IAuthConfig .oauth {
136
136
authRequestHandler(object : IAuthRequestHandler {
137
137
override fun browse (url : String ) {
@@ -149,14 +149,14 @@ class RefreshTokenTest {
149
149
clientId(" my-client-id" )
150
150
repositoryId(RepositoryId (expectedRepoId))
151
151
},
152
- ).build()
153
-
154
- val actualBranches = modelClient.listBranches( RepositoryId (expectedRepoId) )
155
- assertEquals(expectedBranches, actualBranches )
156
- invalidateTokens( )
157
- val actualBranches2 = modelClient.listBranches( RepositoryId (expectedRepoId) )
158
- assertEquals(expectedBranches, actualBranches2 )
159
- assertEquals( 3 , nextTokenSuffix)
152
+ ).build().use { modelClient ->
153
+ val actualBranches = modelClient.listBranches( RepositoryId (expectedRepoId))
154
+ assertEquals(expectedBranches, actualBranches )
155
+ invalidateTokens( )
156
+ val actualBranches2 = modelClient.listBranches( RepositoryId (expectedRepoId) )
157
+ assertEquals(expectedBranches, actualBranches2 )
158
+ assertEquals(3 , nextTokenSuffix )
159
+ }
160
160
}
161
161
}
162
162
@@ -249,7 +249,7 @@ class RefreshTokenTest {
249
249
}
250
250
251
251
runWithServer { port ->
252
- val modelClient = ModelClientV2 .builder().url(" http://localhost:$port " ).authConfig(
252
+ ModelClientV2 .builder().url(" http://localhost:$port " ).authConfig(
253
253
IAuthConfig .oauth {
254
254
authRequestHandler(object : IAuthRequestHandler {
255
255
var loginAlreadyRequested = false
@@ -270,14 +270,14 @@ class RefreshTokenTest {
270
270
clientId(" my-client-id" )
271
271
repositoryId(RepositoryId (expectedRepoId))
272
272
},
273
- ).build()
274
-
275
- val actualBranches = modelClient.listBranches( RepositoryId (expectedRepoId) )
276
- assertEquals(expectedBranches, actualBranches )
277
- invalidateAccessToken( )
278
- val actualBranches2 = modelClient.listBranches( RepositoryId (expectedRepoId) )
279
- assertEquals(expectedBranches, actualBranches2 )
280
- assertEquals( 3 , nextTokenSuffix)
273
+ ).build().use { modelClient ->
274
+ val actualBranches = modelClient.listBranches( RepositoryId (expectedRepoId))
275
+ assertEquals(expectedBranches, actualBranches )
276
+ invalidateAccessToken( )
277
+ val actualBranches2 = modelClient.listBranches( RepositoryId (expectedRepoId) )
278
+ assertEquals(expectedBranches, actualBranches2 )
279
+ assertEquals(3 , nextTokenSuffix )
280
+ }
281
281
}
282
282
}
283
283
}
0 commit comments