How do/did people set up test environments for projects using Riak KV?

Hi all :wave:,

I’ve known Erlang for a few years (was actually my first language, though I’ve mostly been doing some Elixir recently).

I recently inherited an Erlang codebase that uses Riak KV, and I would like to start adding tests.

Since Riak doesn’t support multiple DBs like Postgres, how did people usually set up a test environment — separate cluster, bucket prefixes, or something else?

My local machine isn’t very powerful, I don’t have much container/Docker knowledge, and moving to a different database like Postgres isn’t an option, so I’m curious how teams used to handle this without interfering with dev data.

Any example code or configuration for a test setup would be highly appreciated :folded_hands:

1 Like

You can handle this by creating a dedicated test profile in rebar3 with its own sys_test.config pointing to a separate bucket type or key prefix, so test data won’t clash with dev data. Or you can just use great library meck which is created by @eproxus, for mock data and behavior as for Common Tests as for Unit Tests.

2 Likes

Take a look at the testing harness on GitHub here. There’s a ton of examples there.

2 Likes