File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
main/kotlin/org/modelix/model/server/handlers
test/kotlin/org/modelix/model/server/handlers Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -287,9 +287,9 @@ class ModelReplicationServer(
287
287
val branchRef = repositoryId(repository).getBranchReference(branch)
288
288
checkPermission(ModelServerPermissionSchema .branch(branchRef).query)
289
289
runWithRepository(repository) {
290
- val version = repositoriesManager.getVersion(branchRef)
290
+ val version = repositoriesManager.getVersion(branchRef) ? : throw BranchNotFoundException (branchRef)
291
291
LOG .trace(" Running query on {} @ {}" , branchRef, version)
292
- val initialTree = version!! .getTree()
292
+ val initialTree = version.getTree()
293
293
val otBranch = OTBranch (
294
294
PBranch (initialTree, modelClient.idGenerator),
295
295
modelClient.idGenerator,
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import io.ktor.client.plugins.defaultRequest
28
28
import io.ktor.client.request.accept
29
29
import io.ktor.client.request.delete
30
30
import io.ktor.client.request.get
31
+ import io.ktor.client.request.post
31
32
import io.ktor.client.statement.bodyAsText
32
33
import io.ktor.http.ContentType
33
34
import io.ktor.http.HttpHeaders
@@ -191,6 +192,15 @@ class ModelReplicationServerTest {
191
192
}
192
193
}
193
194
195
+ @Test
196
+ fun `responds with 404 when querying non-existent branch` () = runWithTestModelServer { _, _ ->
197
+ val repositoryId = " abc"
198
+ val branch = " non-existing-branch"
199
+ val response = client.post(" /v2/repositories/$repositoryId /branches/$branch /query" )
200
+ response shouldHaveStatus 404
201
+ assertContains(response.bodyAsText(), " Branch '$branch ' does not exist in repository '$repositoryId '" )
202
+ }
203
+
194
204
@Test
195
205
fun `successfully deletes existing branches` () {
196
206
val repositoryId = RepositoryId (" repo1" )
You can’t perform that action at this time.
0 commit comments