Add network option#1028
Conversation
|
I'm leaving a failing lint: It seems beyond the scope of this PR to do that refactor but let me know if you'd like me to take a crack at it! |
|
Hey @leizor and sorry for taking so long to respond. First, thanks for working on it and for all the effort, I can see how this would be useful to people that use multi-container setup 😼 Regarding the suggested API, I do have a few concerns. I'm not a fan of adding code to explicitly create and remove networks, which is basically a proxy to docker client code. There is little added value. What I think would be really cool though is that you could pass network name without creating it, and gnomock would scan the list of networks, and create one if no networks with the requested name exist. So your tests won't have to deal with the IDs at all, you only specify which network name you need, and it is either used, or created for you. What do you think? Of course then there would be an issue of dangling networks which aren't cleaned up. We would need to leverage the cleaner container for that, or simply document that the networks are created and never removed, at least for now. Regarding the funlen linter warning, I think let's just drop it, it doesn't bring much value IMO. Sorry again for taking so long. Please let me know if you would like to keep working on this, or is it too late 😿 |
|
@orlangure Sounds reasonable! I'll take a look at implementing those changes. |
I was seeking a solution for writing tests that deal with multiple containers that all need to be able to talk to each other.
I found #534 but it looked like it might've gone stale so I decided to build upon the work that they had already started (I hope that's ok!).
Instead of creating the network while starting up containers, I added
gnomock.StartNetworkto explicitly add a network. When creating containers, usegnomock.WithNetworkIDto tell the container to attach to a created network. After the test is done, usegnomock.StopNetworkto remove the network.