First off I'm using Scala and sbt for my application.
I'm using the elastic4s library's ElasticClient to connect to my ES instance. So basically I just need to be able to test these in my unit tests. Such as just verifying that my data actually made it into ES and things like that.
Would mocking ElasticSearch be the best way to go or is there a more efficient way of doing this? And how would I go about either of those?
I've found that you can set up a local client with ElasticClient.local but I can't seem to find many examples. We would like to go with this implementation so if you know how to use this I'd like to hear about it but if there are better or easier ways to complete this that would work.
since elastic search is java and your code is too (or compatible) the best approach would be figure out a way to boot elastic search "embeddable" - just start their server up in your @Before
method and shut it down / clear it in @After
.
luckily for you, it seems like someone already had the exact same idea - https://orrsella.com/2014/10/28/embedded-elasticsearch-server-for-scala-integration-tests/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With