testcontainers-rs icon indicating copy to clipboard operation
testcontainers-rs copied to clipboard

Support overriding "command" for Image

Open Warchant opened this issue 1 year ago • 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.

Warchant avatar Mar 14 '24 21:03 Warchant

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.

jorgehermo9 avatar Mar 16 '24 11:03 jorgehermo9