Hi all, I'm new to ktor and kotlin in general. Hop...
# ktor
d
Hi all, I'm new to ktor and kotlin in general. Hope this question has not been asked too many times: how can environment variables be defined for the tests?
d
Instead of environment variables, you can use configuration properties: https://ktor.io/servers/testing.html#defining-configuration-properties-in-tests
I have used this approach for testing the youkube sample: https://github.com/ktorio/ktor-samples/blob/master/app/youkube/test/YoukubeApplicationTest.kt#L68 Please, check it and let me know if this works for you.
d
Yes, this is working. Thanks a lot.
đź‘Ź 2
now just the part of the injection of environment variables is not being tested, e.g. ktor.deployment.dbUrl = ${dbUrl}
d
Not sure if this hack works as a generic JVM option: https://stackoverflow.com/questions/318239/how-do-i-set-environment-variables-from-java#answer-7201825 Maybe it is possible to hook HOCON to set properties before it tries to read environment variables. (Didn’t tried myself.)
d
Thanks for the info. I'll have a look.