Skip to content

Commit

Permalink
chore: added in size of bytearray
Browse files Browse the repository at this point in the history
  • Loading branch information
MikAoJk committed Oct 20, 2024
1 parent 315823e commit dc6a011
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package no.nav.syfo.fastlegeinformasjon

import io.ktor.http.HttpStatusCode
import io.ktor.server.application.call
import io.ktor.server.request.header
import io.ktor.server.response.respond
import io.ktor.server.response.*
import io.ktor.server.routing.Route
import io.ktor.server.routing.get
import no.nav.syfo.logger
Expand All @@ -24,15 +23,12 @@ fun Route.registerFastlegeinformasjonApi(fastlegeinformasjonService: Fastlegeinf
val fastlegeinformasjonexport =
fastlegeinformasjonService.hentFastlegeinformasjonExport(kommunenr)

if (fastlegeinformasjonexport == null) {
call.respond(
HttpStatusCode.NotFound,
"Fant ikke fastlegeinformasjonexport for kommunenr: $kommunenr",
)
} else {
logger.info("Hentet fastlegeinformasjonexport for kommunenr: $kommunenr")
logger.info("Hentet fastlegeinformasjonexport for kommunenr: $kommunenr")
logger.info(
"Størrelse for kommunenr: $kommunenr er: (${fastlegeinformasjonexport.size / 1024}} KB)",
)

call.respond(fastlegeinformasjonexport)
}
call.respondBytes(fastlegeinformasjonexport)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,24 @@ class FastlegeinformasjonApiTest {
responsebody.shouldBeEqualTo("Mangler header `kommunenr` med kommunenr")
}
}

@Test
internal fun `ExportGPContracts returnerer ok fil over 300 MB`() {
val byteArray = ByteArray(400000000)

every { wsMock.exportGPContracts(any()) } returns byteArray

testApplication {
setUpTestApplication()
routing { registerFastlegeinformasjonApi(fastlegeinformasjonService) }

val response =
client.get("/fastlegeinformasjon") {
header("kommunenr", "0301")
header("Nav-CallId", "callId")
}

response.status.shouldBeEqualTo(HttpStatusCode.OK)
}
}
}

0 comments on commit dc6a011

Please sign in to comment.