Accept a boolean in the no-argument flag setters

Ouverte
#1,530 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 4 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
52/100
Type d'issue
Fonctionnalité
Clarté
Clairement spécifiée
Activité
Active
Stack technique
docker, node.js, typescript
Domaine
api, testing

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.
Langage dominant
TypeScript
Étoiles
2.7k
Forks
290
Merge moyen
4 j 1 h
PR mergées (30 j)
22

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de testcontainers/testcontainers-node

Toutes les issues de testcontainers/testcontainers-node

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.