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
This commit is contained in:
parent
6ce9ff81e7
commit
9c4a2394b4
1 changed files with 24 additions and 8 deletions
|
|
@ -12,9 +12,10 @@ import io.modelcontextprotocol.kotlin.sdk.server.mcp
|
|||
import io.modelcontextprotocol.kotlin.sdk.shared.BaseTransportTest
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.Implementation
|
||||
import io.modelcontextprotocol.kotlin.sdk.types.ServerCapabilities
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.test.BeforeTest
|
||||
import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
import io.ktor.client.plugins.sse.SSE as ClientSSE
|
||||
import io.ktor.server.sse.SSE as ServerSSE
|
||||
|
|
@ -37,7 +38,6 @@ class SseTransportTest : BaseTransportTest() {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore // Ignored because it doesn’t work with wasm/js in Ktor 3.2.3
|
||||
fun `should start then close cleanly`() = runTest {
|
||||
val server = embeddedServer(CIO, port = 0) {
|
||||
install(ServerSSE)
|
||||
|
|
@ -58,13 +58,12 @@ class SseTransportTest : BaseTransportTest() {
|
|||
}
|
||||
|
||||
try {
|
||||
testTransportRead(transport)
|
||||
testTransportOpenClose(transport)
|
||||
} finally {
|
||||
server.stopSuspend()
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun `should read messages`() = runTest {
|
||||
val server = embeddedServer(CIO, port = 0) {
|
||||
|
|
@ -85,20 +84,28 @@ class SseTransportTest : BaseTransportTest() {
|
|||
}
|
||||
}
|
||||
|
||||
val client = Client(
|
||||
clientInfo = Implementation(name = "test-client", version = "1.0"),
|
||||
options = ClientOptions(),
|
||||
)
|
||||
|
||||
try {
|
||||
testTransportRead(transport)
|
||||
withContext(Dispatchers.Default) {
|
||||
client.connect(transport)
|
||||
client.ping()
|
||||
}
|
||||
} finally {
|
||||
client.close()
|
||||
server.stopSuspend()
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun `test sse path not root path`() = runTest {
|
||||
val server = embeddedServer(CIO, port = 0) {
|
||||
install(ServerSSE)
|
||||
routing {
|
||||
mcp { mcpServer }
|
||||
mcp("/sse") { mcpServer }
|
||||
}
|
||||
}.startSuspend(wait = false)
|
||||
|
||||
|
|
@ -114,9 +121,18 @@ class SseTransportTest : BaseTransportTest() {
|
|||
}
|
||||
}
|
||||
|
||||
val client = Client(
|
||||
clientInfo = Implementation(name = "test-client", version = "1.0"),
|
||||
options = ClientOptions(),
|
||||
)
|
||||
|
||||
try {
|
||||
testTransportRead(transport)
|
||||
withContext(Dispatchers.Default) {
|
||||
client.connect(transport)
|
||||
client.ping()
|
||||
}
|
||||
} finally {
|
||||
client.close()
|
||||
server.stopSuspend()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue