Skip to content

This way of adding configuration do not work #713

Answered by HofmeisterAn
akshay-zz asked this question in Q&A
Discussion options

You must be logged in to vote

It does not configure the container. Is this planned or something else is the problem?

This is on purpose. The data held inside the builder is immutable. Each build method call returns a new instance. This allows to share configurations for e.g. for A/B testing, like:

var baseBuilder = new PostgreSqlBuilder()
  .WithUsername("Username")
  .WithPassword("Password")
  .WithLabel("Key", "Value");

var postgres15 = baseBuilder
  .WithImage("postgres:15")
  .Build();

var postgres14 = baseBuilder
  .WithImage("postgres:14")
  .Build();

You can change your example to:

var builder = new TestcontainersBuilder<TestcontainersContainer>();
builder = builder.WithImage("someimage");
builder = builder.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by akshay-zz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants