Skip to content

Commit e4f8ef9

Browse files
committed
fixup! Introduce Kotlin integration tests
1 parent ee7b6b5 commit e4f8ef9

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/ToolEdgeCasesTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class ToolEdgeCasesTest : KotlinTestBase() {
296296
}
297297
""".trimIndent()
298298

299-
actualContent.shouldEqualJson(expectedContent)
299+
actualContent shouldEqualJson expectedContent
300300
}
301301
}
302302

@@ -348,7 +348,7 @@ class ToolEdgeCasesTest : KotlinTestBase() {
348348
}
349349
""".trimIndent()
350350

351-
actualContent.shouldEqualJson(expectedContent)
351+
actualContent shouldEqualJson expectedContent
352352
}
353353
}
354354

@@ -370,7 +370,7 @@ class ToolEdgeCasesTest : KotlinTestBase() {
370370
}
371371
""".trimIndent()
372372

373-
actualContent.shouldEqualJson(expectedContent)
373+
actualContent shouldEqualJson expectedContent
374374
}
375375
}
376376

@@ -396,7 +396,7 @@ class ToolEdgeCasesTest : KotlinTestBase() {
396396
}
397397
""".trimIndent()
398398

399-
actualContent.shouldEqualJson(expectedContent)
399+
actualContent shouldEqualJson expectedContent
400400
}
401401
}
402402

@@ -421,7 +421,7 @@ class ToolEdgeCasesTest : KotlinTestBase() {
421421
}
422422
""".trimIndent()
423423

424-
actualContent.shouldEqualJson(expectedContent)
424+
actualContent shouldEqualJson expectedContent
425425
}
426426
}
427427

kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/kotlin/ToolIntegrationTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class ToolIntegrationTest : KotlinTestBase() {
325325
{"result":"Hello, world!"}
326326
""".trimIndent()
327327

328-
actualContent.shouldEqualJson(expectedContent)
328+
actualContent shouldEqualJson expectedContent
329329
}
330330
}
331331

@@ -361,7 +361,7 @@ class ToolIntegrationTest : KotlinTestBase() {
361361
}
362362
""".trimIndent()
363363

364-
actualContent.shouldEqualJson(expectedContent)
364+
actualContent shouldEqualJson expectedContent
365365
}
366366
}
367367

@@ -378,7 +378,7 @@ class ToolIntegrationTest : KotlinTestBase() {
378378
}
379379
""".trimIndent()
380380

381-
actualContent.shouldEqualJson(expectedContent)
381+
actualContent shouldEqualJson expectedContent
382382

383383
val errorArgs = mapOf(
384384
"errorType" to "error",
@@ -394,7 +394,7 @@ class ToolIntegrationTest : KotlinTestBase() {
394394
}
395395
""".trimIndent()
396396

397-
actualError.shouldEqualJson(expectedError)
397+
actualError shouldEqualJson expectedError
398398

399399
val exceptionArgs = mapOf(
400400
"errorType" to "exception",
@@ -451,7 +451,7 @@ class ToolIntegrationTest : KotlinTestBase() {
451451
}
452452
""".trimIndent()
453453

454-
actualContent.shouldEqualJson(expectedContent)
454+
actualContent shouldEqualJson expectedContent
455455

456456
val textOnlyArgs = mapOf(
457457
"text" to testText,

kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration/typescript/TypeScriptTestBase.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,9 @@ abstract class TypeScriptTestBase {
5757
}
5858

5959
println("Installing TypeScript SDK dependencies")
60-
executeCommand("npm install", sdkDir)
60+
executeCommand("npm install", sdkDir, allowFailure = false, timeoutSeconds = null)
6161
}
6262

63-
@JvmStatic
64-
protected fun executeCommand(command: String, workingDir: File): String =
65-
runCommand(command, workingDir, allowFailure = false, timeoutSeconds = null)
66-
6763
@JvmStatic
6864
protected fun killProcessOnPort(port: Int) {
6965
val isWindows = System.getProperty("os.name").lowercase().contains("windows")
@@ -72,7 +68,7 @@ abstract class TypeScriptTestBase {
7268
} else {
7369
"lsof -ti:$port | xargs kill -9 2>/dev/null || true"
7470
}
75-
runCommand(killCommand, File("."), allowFailure = true, timeoutSeconds = null)
71+
executeCommand(killCommand, File("."), allowFailure = true, timeoutSeconds = null)
7672
}
7773

7874
@JvmStatic
@@ -82,11 +78,12 @@ abstract class TypeScriptTestBase {
8278
}
8379
}
8480

85-
private fun runCommand(
81+
@JvmStatic
82+
protected fun executeCommand(
8683
command: String,
8784
workingDir: File,
88-
allowFailure: Boolean,
89-
timeoutSeconds: Long?,
85+
allowFailure: Boolean = false,
86+
timeoutSeconds: Long? = null,
9087
): String {
9188
if (!workingDir.exists()) {
9289
if (!workingDir.mkdirs()) {
@@ -174,7 +171,7 @@ abstract class TypeScriptTestBase {
174171
}
175172

176173
protected fun executeCommandAllowingFailure(command: String, workingDir: File, timeoutSeconds: Long = 20): String =
177-
runCommand(command, workingDir, allowFailure = true, timeoutSeconds = timeoutSeconds)
174+
executeCommand(command, workingDir, allowFailure = true, timeoutSeconds = timeoutSeconds)
178175

179176
protected fun startTypeScriptServer(port: Int): Process {
180177
killProcessOnPort(port)
@@ -227,7 +224,7 @@ abstract class TypeScriptTestBase {
227224
}
228225
}
229226

230-
private suspend fun newClient(serverUrl: String): Client =
227+
protected suspend fun newClient(serverUrl: String): Client =
231228
HttpClient(CIO) { install(SSE) }.mcpStreamableHttp(serverUrl)
232229

233230
protected suspend fun <T> withClient(serverUrl: String, block: suspend (Client) -> T): T {

0 commit comments

Comments
 (0)