Skip to content

Commit da5c90b

Browse files
committed
test: attempt to fix the flaky test refresh token is used to fetch new tokens
1 parent 384f05d commit da5c90b

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

model-client/src/jvmTest/kotlin/org/modelix/model/client2/RefreshTokenTest.kt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class RefreshTokenTest {
131131
}
132132

133133
runWithServer { port ->
134-
val modelClient = ModelClientV2.builder().url("http://localhost:$port").authConfig(
134+
ModelClientV2.builder().url("http://localhost:$port").authConfig(
135135
IAuthConfig.oauth {
136136
authRequestHandler(object : IAuthRequestHandler {
137137
override fun browse(url: String) {
@@ -149,14 +149,14 @@ class RefreshTokenTest {
149149
clientId("my-client-id")
150150
repositoryId(RepositoryId(expectedRepoId))
151151
},
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+
}
160160
}
161161
}
162162

@@ -249,7 +249,7 @@ class RefreshTokenTest {
249249
}
250250

251251
runWithServer { port ->
252-
val modelClient = ModelClientV2.builder().url("http://localhost:$port").authConfig(
252+
ModelClientV2.builder().url("http://localhost:$port").authConfig(
253253
IAuthConfig.oauth {
254254
authRequestHandler(object : IAuthRequestHandler {
255255
var loginAlreadyRequested = false
@@ -270,14 +270,14 @@ class RefreshTokenTest {
270270
clientId("my-client-id")
271271
repositoryId(RepositoryId(expectedRepoId))
272272
},
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+
}
281281
}
282282
}
283283
}

0 commit comments

Comments
 (0)