This way of adding configuration do not work #713
-
var builder = new TestcontainersBuilder<TestcontainersContainer>();
builder.WithImage("someimage");
builder.WithName("someContainerName");
var container = builder.Build(); It does not configure the container. Is this planned or something else is the problem? Although the following works the way it should var container = new TestcontainersBuilder<TestcontainersContainer>()
.WithImage("someImage")
.WithName("containerName")
.Build(); |
Beta Was this translation helpful? Give feedback.
Answered by
HofmeisterAn
Dec 14, 2022
Replies: 1 comment
-
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.WithName("someContainerName");
var container = builder.Build(); |
Beta Was this translation helpful? Give feedback.
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
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:
You can change your example to: