Remove the `Uuid` test seam from public constructors

Open
#1,561 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
docker, node.js, typescript
Domain
api, testing-qa

Research direction

Read the three listed constructor files and inspect the Uuid, RandomUuid, and randomUuid exports. Start by checking the dependency on #1535 and the existing withProjectName pattern; decide how deterministic names should be supplied for Network and GenericContainerBuilder. Done means public constructors accept user-facing arguments, tests can still choose deterministic names, and the UUID exports are removed; the issue does not name test files.

Written by the indexing model from the issue text.

Description

maintenance major

What happens

Three public constructors take a Uuid parameter that exists only so tests can inject deterministic names:

  • new Network(uuid?)
  • new DockerComposeEnvironment(composeFilePath, composeFiles, uuid?)
  • new GenericContainerBuilder(context, dockerfileName, uuid?)

It is the reason Uuid, RandomUuid and randomUuid are exported from the package. For Network it is the only constructor parameter, which takes the slot that real options would use.

Expected

Public constructors take only user-facing arguments. Tests get deterministic names another way, for example a withName/withProjectName style setter or an internal factory.

Where

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

Notes

  • Removing a constructor parameter and the Uuid exports is breaking, hence major.
  • DockerComposeEnvironment already has withProjectName, which covers its use of the seam.

Dependencies

  • Blocked by #1535: Network needs a real way to set a name before its only constructor parameter is removed.
Dominant language
TypeScript
Stars
2.7k
Forks
290
Avg merge
4d 1h
Merged PRs (30d)
22

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from testcontainers/testcontainers-node

All issues in testcontainers/testcontainers-node

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.