-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from craigatk/version
(feature) Adding endpoint that shows application version
- Loading branch information
Showing
6 changed files
with
56 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
src/main/resources/static | ||
src/main/resources/version.json | ||
|
||
.kotlintest |
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
11 changes: 11 additions & 0 deletions
11
server/server-app/src/main/kotlin/projektor/route/VersionRoutes.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,11 @@ | ||
package projektor.route | ||
|
||
import io.ktor.http.content.defaultResource | ||
import io.ktor.http.content.static | ||
import io.ktor.routing.Route | ||
|
||
fun Route.version() { | ||
static("/version") { | ||
defaultResource("version.json", "/") | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
server/server-app/src/test/kotlin/projektor/version/VersionApplicationTest.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,27 @@ | ||
package projektor.version | ||
|
||
import io.ktor.http.HttpMethod | ||
import io.ktor.http.HttpStatusCode | ||
import io.ktor.server.testing.handleRequest | ||
import io.ktor.server.testing.withTestApplication | ||
import io.ktor.util.KtorExperimentalAPI | ||
import org.junit.jupiter.api.Test | ||
import projektor.ApplicationTestCase | ||
import strikt.api.expectThat | ||
import strikt.assertions.contains | ||
import strikt.assertions.isEqualTo | ||
import strikt.assertions.isNotNull | ||
|
||
@KtorExperimentalAPI | ||
class VersionApplicationTest : ApplicationTestCase() { | ||
@Test | ||
fun `should provide version endpoint`() { | ||
withTestApplication(::createTestApplication) { | ||
handleRequest(HttpMethod.Get, "/version").apply { | ||
expectThat(response.status()).isEqualTo(HttpStatusCode.OK) | ||
|
||
expectThat(response.content).isNotNull().and { contains("version") } | ||
} | ||
} | ||
} | ||
} |