Skip to content

Commit 2fbd236

Browse files
committed
chore: fix UTs
1 parent 11b9253 commit 2fbd236

File tree

4 files changed

+42
-26
lines changed

4 files changed

+42
-26
lines changed

src/main/kotlin/com/coder/gateway/settings/CoderSettings.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ open class CoderSettingsState(
114114
// Default version of IDE to display in IDE selection dropdown
115115
open var defaultIde: String = "",
116116
// Whether to check for IDE updates.
117-
open var checkIDEUpdates: Boolean = true,
117+
open var checkIDEUpdates: Boolean = true
118118
)
119119

120120
/**
@@ -142,7 +142,7 @@ open class CoderSettings(
142142
// Overrides the default environment (for tests).
143143
private val env: Environment = Environment(),
144144
// Overrides the default binary name (for tests).
145-
private val binaryName: String? = null,
145+
private val binaryName: String? = null
146146
) {
147147
val tls = CoderTLSSettings(state)
148148

src/test/kotlin/com/coder/gateway/cli/CoderCLIManagerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ internal class CoderCLIManagerTest {
124124
CoderSettings(
125125
CoderSettingsState(
126126
dataDirectory = tmpdir.resolve("cli-data-dir").toString(),
127-
binaryDirectory = tmpdir.resolve("cli-bin-dir").toString(),
127+
binaryDirectory = tmpdir.resolve("cli-bin-dir").toString()
128128
),
129129
)
130130
val url = URL("http://localhost")

src/test/kotlin/com/coder/gateway/sdk/CoderRestClientTest.kt

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -229,31 +229,44 @@ class CoderRestClientTest {
229229
// Nothing, so no resources.
230230
emptyList(),
231231
// One workspace with an agent, but no resources.
232-
listOf(TestWorkspace(DataGen.workspace("ws1", agents = mapOf("agent1" to "3f51da1d-306f-4a40-ac12-62bda5bc5f9a")))),
232+
listOf(
233+
TestWorkspace(
234+
DataGen.workspace(
235+
"ws1",
236+
agents = mapOf("agent1" to "3f51da1d-306f-4a40-ac12-62bda5bc5f9a")
237+
)
238+
)
239+
),
233240
// One workspace with an agent and resources that do not match the agent.
234241
listOf(
235242
TestWorkspace(
236-
workspace = DataGen.workspace("ws1", agents = mapOf("agent1" to "3f51da1d-306f-4a40-ac12-62bda5bc5f9a")),
237-
resources =
238-
listOf(
239-
DataGen.resource("agent2", "968eea5e-8787-439d-88cd-5bc440216a34"),
240-
DataGen.resource("agent3", "72fbc97b-952c-40c8-b1e5-7535f4407728"),
243+
workspace = DataGen.workspace(
244+
"ws1",
245+
agents = mapOf("agent1" to "3f51da1d-306f-4a40-ac12-62bda5bc5f9a")
241246
),
247+
resources =
248+
listOf(
249+
DataGen.resource("agent2", "968eea5e-8787-439d-88cd-5bc440216a34"),
250+
DataGen.resource("agent3", "72fbc97b-952c-40c8-b1e5-7535f4407728"),
251+
),
242252
),
243253
),
244254
// Multiple workspaces but only one has resources.
245255
listOf(
246256
TestWorkspace(
247-
workspace = DataGen.workspace("ws1", agents = mapOf("agent1" to "3f51da1d-306f-4a40-ac12-62bda5bc5f9a")),
257+
workspace = DataGen.workspace(
258+
"ws1",
259+
agents = mapOf("agent1" to "3f51da1d-306f-4a40-ac12-62bda5bc5f9a")
260+
),
248261
resources = emptyList(),
249262
),
250263
TestWorkspace(
251264
workspace = DataGen.workspace("ws2"),
252265
resources =
253-
listOf(
254-
DataGen.resource("agent2", "968eea5e-8787-439d-88cd-5bc440216a34"),
255-
DataGen.resource("agent3", "72fbc97b-952c-40c8-b1e5-7535f4407728"),
256-
),
266+
listOf(
267+
DataGen.resource("agent2", "968eea5e-8787-439d-88cd-5bc440216a34"),
268+
DataGen.resource("agent3", "72fbc97b-952c-40c8-b1e5-7535f4407728"),
269+
),
257270
),
258271
TestWorkspace(
259272
workspace = DataGen.workspace("ws3"),
@@ -272,7 +285,8 @@ class CoderRestClientTest {
272285
val matches = resourceEndpoint.find(exchange.requestURI.path)
273286
if (matches != null) {
274287
val templateVersionId = UUID.fromString(matches.destructured.toList()[0])
275-
val ws = workspaces.firstOrNull { it.workspace.latestBuild.templateVersionID == templateVersionId }
288+
val ws =
289+
workspaces.firstOrNull { it.workspace.latestBuild.templateVersionID == templateVersionId }
276290
if (ws != null) {
277291
val body =
278292
moshi.adapter<List<WorkspaceResource>>(
@@ -326,7 +340,8 @@ class CoderRestClientTest {
326340
val buildMatch = buildEndpoint.find(exchange.requestURI.path)
327341
if (buildMatch != null) {
328342
val workspaceId = UUID.fromString(buildMatch.destructured.toList()[0])
329-
val json = moshi.adapter(CreateWorkspaceBuildRequest::class.java).fromJson(exchange.requestBody.source().buffer())
343+
val json = moshi.adapter(CreateWorkspaceBuildRequest::class.java)
344+
.fromJson(exchange.requestBody.source().buffer())
330345
if (json == null) {
331346
val response = Response("No body", "No body for create workspace build request")
332347
val body = moshi.adapter(Response::class.java).toJson(response).toByteArray()
@@ -396,8 +411,8 @@ class CoderRestClientTest {
396411
CoderSettings(
397412
CoderSettingsState(
398413
tlsCAPath = Path.of("src/test/fixtures/tls", "self-signed.crt").toString(),
399-
tlsAlternateHostname = "localhost",
400-
),
414+
tlsAlternateHostname = "localhost"
415+
)
401416
)
402417
val user = DataGen.user()
403418
val (srv, url) = mockTLSServer("self-signed")
@@ -422,8 +437,8 @@ class CoderRestClientTest {
422437
CoderSettings(
423438
CoderSettingsState(
424439
tlsCAPath = Path.of("src/test/fixtures/tls", "self-signed.crt").toString(),
425-
tlsAlternateHostname = "fake.example.com",
426-
),
440+
tlsAlternateHostname = "fake.example.com"
441+
)
427442
)
428443
val (srv, url) = mockTLSServer("self-signed")
429444
val client = CoderRestClient(URL(url), "token", settings)
@@ -441,8 +456,8 @@ class CoderRestClientTest {
441456
val settings =
442457
CoderSettings(
443458
CoderSettingsState(
444-
tlsCAPath = Path.of("src/test/fixtures/tls", "self-signed.crt").toString(),
445-
),
459+
tlsCAPath = Path.of("src/test/fixtures/tls", "self-signed.crt").toString()
460+
)
446461
)
447462
val (srv, url) = mockTLSServer("no-signing")
448463
val client = CoderRestClient(URL(url), "token", settings)
@@ -461,7 +476,7 @@ class CoderRestClientTest {
461476
CoderSettings(
462477
CoderSettingsState(
463478
tlsCAPath = Path.of("src/test/fixtures/tls", "chain-root.crt").toString(),
464-
),
479+
)
465480
)
466481
val user = DataGen.user()
467482
val (srv, url) = mockTLSServer("chain")
@@ -505,7 +520,8 @@ class CoderRestClientTest {
505520
"bar",
506521
true,
507522
object : ProxySelector() {
508-
override fun select(uri: URI): List<Proxy> = listOf(Proxy(Proxy.Type.HTTP, InetSocketAddress("localhost", srv2.address.port)))
523+
override fun select(uri: URI): List<Proxy> =
524+
listOf(Proxy(Proxy.Type.HTTP, InetSocketAddress("localhost", srv2.address.port)))
509525

510526
override fun connectFailed(
511527
uri: URI,

src/test/kotlin/com/coder/gateway/settings/CoderSettingsTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ internal class CoderSettingsTest {
6363
"HOME" to "/tmp/coder-gateway-test/home",
6464
"XDG_DATA_HOME" to "/tmp/coder-gateway-test/xdg-data",
6565
),
66-
),
66+
)
6767
)
6868
var expected =
6969
when (getOS()) {
@@ -408,7 +408,7 @@ internal class CoderSettingsTest {
408408
disableAutostart = getOS() != OS.MAC,
409409
setupCommand = "test setup",
410410
ignoreSetupFailure = true,
411-
sshLogDirectory = "test ssh log directory",
411+
sshLogDirectory = "test ssh log directory"
412412
),
413413
)
414414

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy