Skip to content

Commit 9c4a239

Browse files
authored
test: remove Ignore for SseTransportTest and refactor (#662)
SseTransportTest passes on wasm after updating ktor ## How Has This Been Tested? jvm/js/wasm/macos ## Breaking Changes none ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed
1 parent 6ce9ff8 commit 9c4a239

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

  • integration-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client

integration-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/SseTransportTest.kt

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import io.modelcontextprotocol.kotlin.sdk.server.mcp
1212
import io.modelcontextprotocol.kotlin.sdk.shared.BaseTransportTest
1313
import io.modelcontextprotocol.kotlin.sdk.types.Implementation
1414
import io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities
15+
import kotlinx.coroutines.Dispatchers
1516
import kotlinx.coroutines.test.runTest
17+
import kotlinx.coroutines.withContext
1618
import kotlin.test.BeforeTest
17-
import kotlin.test.Ignore
1819
import kotlin.test.Test
1920
import io.ktor.client.plugins.sse.SSE as ClientSSE
2021
import io.ktor.server.sse.SSE as ServerSSE
@@ -37,7 +38,6 @@ class SseTransportTest : BaseTransportTest() {
3738
}
3839

3940
@Test
40-
@Ignore // Ignored because it doesn’t work with wasm/js in Ktor 3.2.3
4141
fun `should start then close cleanly`() = runTest {
4242
val server = embeddedServer(CIO, port = 0) {
4343
install(ServerSSE)
@@ -58,13 +58,12 @@ class SseTransportTest : BaseTransportTest() {
5858
}
5959

6060
try {
61-
testTransportRead(transport)
61+
testTransportOpenClose(transport)
6262
} finally {
6363
server.stopSuspend()
6464
}
6565
}
6666

67-
@Ignore
6867
@Test
6968
fun `should read messages`() = runTest {
7069
val server = embeddedServer(CIO, port = 0) {
@@ -85,20 +84,28 @@ class SseTransportTest : BaseTransportTest() {
8584
}
8685
}
8786

87+
val client = Client(
88+
clientInfo = Implementation(name = "test-client", version = "1.0"),
89+
options = ClientOptions(),
90+
)
91+
8892
try {
89-
testTransportRead(transport)
93+
withContext(Dispatchers.Default) {
94+
client.connect(transport)
95+
client.ping()
96+
}
9097
} finally {
98+
client.close()
9199
server.stopSuspend()
92100
}
93101
}
94102

95-
@Ignore
96103
@Test
97104
fun `test sse path not root path`() = runTest {
98105
val server = embeddedServer(CIO, port = 0) {
99106
install(ServerSSE)
100107
routing {
101-
mcp { mcpServer }
108+
mcp("/sse") { mcpServer }
102109
}
103110
}.startSuspend(wait = false)
104111

@@ -114,9 +121,18 @@ class SseTransportTest : BaseTransportTest() {
114121
}
115122
}
116123

124+
val client = Client(
125+
clientInfo = Implementation(name = "test-client", version = "1.0"),
126+
options = ClientOptions(),
127+
)
128+
117129
try {
118-
testTransportRead(transport)
130+
withContext(Dispatchers.Default) {
131+
client.connect(transport)
132+
client.ping()
133+
}
119134
} finally {
135+
client.close()
120136
server.stopSuspend()
121137
}
122138
}

0 commit comments

Comments
 (0)