testcontainers/testcontainers-rs

Support overriding "command" for Image

Closed this issue · 1 comments

Current Image supports overriding entrypoint, and env_vars. I also need to override command.

Use-case is - I want to run multiple instances of the same server (on different ports), each will have --name={1,2,3} additional flag.

With current type Args; implementation I can only hardcode a single "default" command, but cannot dynamically append new args directly in the test.

It is true that the RunnableImage struct does not have a with_args method, but it is possible to create a RunnableImage with other than the default args.

For example, given MyCustomImage struct that implements the trait Image<Args=Vec<String>>, you can create a RunnableImage with custom args this way: (MyCustomImage,vec!["first-arg","second-arg"]).into::<RunnableImage>()

See this

Although this, you are right that it would be useful that the RunnableImage has a with_args method. I've submitted a PR addressing this #558.