The test as simple as this: ```"Not allow logging ...
# koin
m
The test as simple as this:
Copy code
"Not allow logging in with incorrect api key" {
                // given
                val payload = JsonObject(
                    mapOf(
                        "apikey" to JsonPrimitive("wrong"),
                        "username" to JsonPrimitive("jamma"),
                    )
                )
                // when
                testApplication {
                    application { Application::testModule }
                    environment {
                        config = ApplicationConfig("test-application.conf")
                    }
                    val client = createClient { install(ContentNegotiation) { json() } }

                    val response = <http://client.post|client.post>("api/login") {
                        contentType(ContentType.Application.Json)
                        setBody(payload)
                    }

                    // then
                    response shouldHaveStatus HttpStatusCode.Unauthorized
                }
            }
I’m using KoinExtensions to inject the dependencies.
Copy code
override fun extensions(): List<Extension> =
        listOf(KoinExtension(listOf(testDbModule, testHttpModule, RepositoryModule)))
a
nothing on Koin in your stack? can you check in pure Ktor sample?
m
I will push something later today.
I have the Koin Ktor project with modules firing on Application setup
The tests ComplexDIRoutingTest and ComplexDIRoutingWithoutKoinTest display the issue I’m having. A different problem, that I have, that I try to resolve is the fact that I’m not able to override the default module in tests, I need to konfigure Koin separatly with the final (test) module implementations.
a
Interesting, did you linked all your resources in the issue?
m
yes.
the problem i;m getting is that there is a Casting issue when trying to inject that depencency
@arnaud.giuliani do you have any ideas why my getting this issue ?