orlangure / gnomock

Test your code without writing mocks with ephemeral Docker containers 📦 Setup popular services with just a couple lines of code ⏱️ No bash, no yaml, only code 💻
MIT License
1.39k stars 67 forks source link

Implement DynamoDB preset #53

Open orlangure opened 4 years ago

orlangure commented 4 years ago

A short guide on implementing a new preset: https://github.com/orlangure/gnomock/blob/master/CONTRIBUTING.md#new-presets

MySQL preset for inspiration: https://github.com/orlangure/gnomock/tree/master/preset/mysql

The objective is to implement a new Preset that spins up DynamoDB docker container, sets up its initial state (user provided data), waits for it to become ready and kills it in the end.

Please note that there are multiple steps required to create a new preset (see the guide above). I'm here to help😼

imsk17 commented 4 years ago

Hi, Can I work on this issue?

orlangure commented 4 years ago

Hi, @imsk17! Of course. Thank you! If you need any help getting started, I'm here to help.

imsk17 commented 4 years ago

it seems this isn't easy. dynamodb requires structs before it makes a table. so u cannot use map[string]interface{}

orlangure commented 4 years ago

@imsk17, that's fine! I think we should go for quick wins, and having a working preset that creates a dynamodb container, even without initial data, would be great.

What do you think about narrowing the scope of this issue to implementing a preset that only has a working healthcheck function?

If in the future somebody requests initial setup, we handle it then.

imsk17 commented 4 years ago

or maybe we can setup a withStructs() method?

orlangure commented 4 years ago

I think it would complicate the development too much for the value it provides. If you'd like to work on initial data setup in dynamodb, I'd recommend to work on it as an independent task right after we merge a minimal working preset.

imsk17 commented 4 years ago

okay! thats fine

checkaayush commented 3 years ago

@imsk17 Are you still working on this?

imsk17 commented 3 years ago

quite busy nowadays. you can do it if you want to

nawa commented 3 years ago

@orlangure Why not to use DynamoDB from localstack and you decided to create a separate preset?

orlangure commented 3 years ago

@nawa, I think using the official docker image would be as close to the real thing as possible, probably closer than Localstack implementation.

Another factor is the API. Take Localstack S3 for example. We have WithS3Files option, which would be useless if you only need Localstack container to test SQS. Eventually the number of Localstack options could grow too much and add too much noise, so I'd rather "move" these options into separate, dedicated presets wherever possible.

The third factor which I'm not entirely sure about is startup speed. I assume that starting Localstack would take more time than just a DynamoDB container.

But I'm of course glad that there is an option to use DynamoDB via Localstack even though there are no initial state setup features like with other databases.