Join Slack
Powered by
Hi all, I'm new to ktor and kotlin in general. Hop...
# ktor
d
danielm
04/16/2018, 12:35 PM
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
Deactivated User
04/16/2018, 12:41 PM
Instead of environment variables, you can use configuration properties:
https://ktor.io/servers/testing.html#defining-configuration-properties-in-tests
Deactivated User
04/16/2018, 12:42 PM
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
danielm
04/16/2018, 1:02 PM
Yes, this is working. Thanks a lot.
👏 2
danielm
04/16/2018, 1:07 PM
now just the part of the injection of environment variables is not being tested, e.g. ktor.deployment.dbUrl = ${dbUrl}
d
Deactivated User
04/16/2018, 1:11 PM
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
danielm
04/16/2018, 1:14 PM
Thanks for the info. I'll have a look.
3
Views
Open in Slack
Previous
Next