-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose Ls via grpc to enable demo building (#108)
- Loading branch information
Showing
7 changed files
with
124 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
server/src/test/kotlin/io/typestream/grpc/FileSystemServiceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package io.typestream.grpc | ||
|
||
import io.grpc.inprocess.InProcessChannelBuilder | ||
import io.grpc.inprocess.InProcessServerBuilder | ||
import io.grpc.testing.GrpcCleanupRule | ||
import io.typestream.Server | ||
import io.typestream.config.testing.testConfig | ||
import io.typestream.grpc.filesystem_service.FileSystemServiceGrpc | ||
import io.typestream.grpc.filesystem_service.lsRequest | ||
import io.typestream.testing.TestKafka | ||
import io.typestream.testing.until | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.runBlocking | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Rule | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.testcontainers.junit.jupiter.Container | ||
import org.testcontainers.junit.jupiter.Testcontainers | ||
|
||
@Testcontainers | ||
internal class FileSystemServiceTest { | ||
private val dispatcher = Dispatchers.IO | ||
|
||
private lateinit var app: Server | ||
|
||
@get:Rule | ||
val grpcCleanupRule: GrpcCleanupRule = GrpcCleanupRule() | ||
|
||
@Container | ||
private val testKafka = TestKafka() | ||
|
||
@BeforeEach | ||
fun beforeEach() { | ||
app = Server(testConfig(testKafka), dispatcher) | ||
} | ||
|
||
@Test | ||
fun `returns filesystem paths`(): Unit = runBlocking { | ||
app.use { | ||
val serverName = InProcessServerBuilder.generateName() | ||
launch(dispatcher) { | ||
app.run(InProcessServerBuilder.forName(serverName).directExecutor()) | ||
} | ||
|
||
until { requireNotNull(app.server) } | ||
|
||
grpcCleanupRule.register(app.server ?: return@use) | ||
|
||
val stub = FileSystemServiceGrpc.newBlockingStub( | ||
grpcCleanupRule.register(InProcessChannelBuilder.forName(serverName).directExecutor().build()) | ||
) | ||
|
||
val path = lsRequest { path = "/" } | ||
|
||
assertThat(stub.ls(path)) | ||
.extracting("filesList") | ||
.isEqualTo(listOf("dev", "mnt")) | ||
|
||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters