Accept a boolean in the no-argument flag setters

Aperta
#1,530 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, node.js, typescript
Ambito
api, testing

Direzione di ricerca

Start with the listed generic container, builder, Docker Compose environment, and test files; compare the six no-argument setters with the existing boolean setters. Check the related work in #1524 and coordinate the shared TestContainer interface edit with #1529. Done means the flag setters accept an optional boolean defaulting to true, existing calls still work, conditional calls can turn flags off, and tests cover the behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement minor

What happens

On/off settings are spelled two ways.

No argument, can only switch on:

  • GenericContainer.withReuse()
  • GenericContainer.withPrivilegedMode()
  • GenericContainer.withDefaultLogDriver()
  • DockerComposeEnvironment.withBuild()
  • DockerComposeEnvironment.withNoRecreate()
  • GenericContainerBuilder.withBuildkit()

Boolean argument:

  • GenericContainer.withAutoCleanup(boolean)
  • GenericContainer.withAutoRemove(boolean)
  • DockerComposeEnvironment.withAutoCleanup(boolean)
  • GenericContainerBuilder.withCache(boolean)

The no-argument form breaks the chain for conditional settings and cannot undo a setting that a subclass or module turned on:

const container = new GenericContainer(image).withExposedPorts(8080);
if (!process.env.CI) {
  container.withReuse();
}

The modules are split the same way: 6 no-argument flag setters and 4 that take a boolean.

Expected

Flag setters accept an optional boolean that defaults to true, so withReuse() keeps working and withReuse(!process.env.CI) becomes possible.

Where

  • packages/testcontainers/src/generic-container/generic-container.ts
  • packages/testcontainers/src/generic-container/generic-container-builder.ts
  • packages/testcontainers/src/docker-compose-environment/docker-compose-environment.ts
  • packages/testcontainers/src/test-container.ts

Notes

  • Java takes a boolean in both withReuse(boolean reusable) and withPrivilegedMode(boolean mode).
  • Worth adding the convention to the add-module skill.

Dependencies

  • Stack on #1524: both change withNoRecreate.
  • Coordinate with #1529: both edit the TestContainer interface.
Lingua principale
TypeScript
Stelle
2.7k
Fork
290
Merge medio
4g 1h
PR unite (30g)
22

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di testcontainers/testcontainers-node

Tutte le issue di testcontainers/testcontainers-node

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.