Skip to content

feat(postgres): add WithOrderedInitScripts for Postgres testcontainers #3121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 24, 2025

Conversation

mdelapenya
Copy link
Member

Type of change: Enhancement

What does this PR do?

As suggested in the discussion, this adds a brand new option to add init scripts to your Postgres testcontainer, and run them in the order that the user provides them to the function.

It also further documents WithInitScripts to clarify in what order the scripts are executed.

Why is it important?

The files that are passed to WithInitScripts are copied inside the container, then run in alphanumerical order. I believe this is surprising behavior, as I expect the init scripts to be run in the order I passed them to testcontainers.

Someone ran into this behavior before and raised an issue : #2542

Related issues

How to test this PR

Try using the newly-added function WithOrderedInitScripts for the postgres container.
Any setup using WithInitScripts should work just like before.

AlisCode and others added 6 commits April 16, 2025 09:03
* main:
  feat(redis): add TLS support (testcontainers#3115)
  feat: add Docker Model Runner module (testcontainers#3106)
  feat: add toxiproxy module (testcontainers#3092)
  chore(ci): run core tests on Testcontainers Cloud (testcontainers#3117)
  deps(aerospike): replace core module in go.mod (testcontainers#3116)
  chore(deps): bump golang.org/x/net from 0.36.0 to 0.38.0 in /modules and /examples (testcontainers#3114)
  chore(ci): revert codeql improvements for CI resiliency (testcontainers#3112)
  docs(socat): add missing version marker for new options (testcontainers#3111)
@mdelapenya mdelapenya added the feature New functionality or new behaviors on the existing one label Apr 24, 2025
@mdelapenya mdelapenya self-assigned this Apr 24, 2025
@mdelapenya mdelapenya requested a review from a team as a code owner April 24, 2025 10:06
@mdelapenya mdelapenya changed the title Alis code/main feat(postgres): add WithOrderedInitScripts for Postgres testcontainers Apr 24, 2025
Copy link

netlify bot commented Apr 24, 2025

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 2c81b56
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/680a0d43f47732000850ccd0
😎 Deploy Preview https://deploy-preview-3121--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mdelapenya mdelapenya changed the title feat(postgres): add WithOrderedInitScripts for Postgres testcontainers feat(postgres): add WithOrderedInitScripts for Postgres testcontainers Apr 24, 2025
@mdelapenya mdelapenya merged commit 66401ba into testcontainers:main Apr 24, 2025
15 checks passed
@mdelapenya mdelapenya deleted the AlisCode/main branch April 24, 2025 10:17
mdelapenya added a commit to xBlaz3kx/testcontainers-go that referenced this pull request Apr 24, 2025
* main:
  feat(postgres): add WithOrderedInitScripts for Postgres testcontainers (testcontainers#3121)
  feat(redis): add TLS support (testcontainers#3115)
  feat: add Docker Model Runner module (testcontainers#3106)
  feat: add toxiproxy module (testcontainers#3092)
  chore(ci): run core tests on Testcontainers Cloud (testcontainers#3117)
  deps(aerospike): replace core module in go.mod (testcontainers#3116)
  chore(deps): bump golang.org/x/net from 0.36.0 to 0.38.0 in /modules and /examples (testcontainers#3114)
  chore(ci): revert codeql improvements for CI resiliency (testcontainers#3112)
  docs(socat): add missing version marker for new options (testcontainers#3111)
  deps: use pinned dependencies on GH actions (testcontainers#3110)
  chore(deps): bump jinja2 from 3.1.5 to 3.1.6 (testcontainers#3109)
  chore(ci): reduce GH runners usage by calling codeql in the lint stage (testcontainers#3108)
  deps(ci): use python 3.13 on Netlify deployments (testcontainers#3107)
mdelapenya added a commit that referenced this pull request Apr 24, 2025
…properties-1.8.10

* main:
  feat(postgres): add WithOrderedInitScripts for Postgres testcontainers (#3121)
  feat(redis): add TLS support (#3115)
  feat: add Docker Model Runner module (#3106)
mdelapenya added a commit to jm96441n/testcontainers-go that referenced this pull request Apr 24, 2025
* main:
  feat(postgres): add WithOrderedInitScripts for Postgres testcontainers (testcontainers#3121)
  feat(redis): add TLS support (testcontainers#3115)
  feat: add Docker Model Runner module (testcontainers#3106)
  feat: add toxiproxy module (testcontainers#3092)
  chore(ci): run core tests on Testcontainers Cloud (testcontainers#3117)
  deps(aerospike): replace core module in go.mod (testcontainers#3116)
  chore(deps): bump golang.org/x/net from 0.36.0 to 0.38.0 in /modules and /examples (testcontainers#3114)
  chore(ci): revert codeql improvements for CI resiliency (testcontainers#3112)
  docs(socat): add missing version marker for new options (testcontainers#3111)
mdelapenya added a commit to georgespalding/testcontainers-go that referenced this pull request Apr 25, 2025
* main:
  feat(postgres): add WithOrderedInitScripts for Postgres testcontainers (testcontainers#3121)
  feat(redis): add TLS support (testcontainers#3115)
  feat: add Docker Model Runner module (testcontainers#3106)
  feat: add toxiproxy module (testcontainers#3092)
  chore(ci): run core tests on Testcontainers Cloud (testcontainers#3117)
  deps(aerospike): replace core module in go.mod (testcontainers#3116)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or new behaviors on the existing one
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement]: Postgres WithInitScripts files should be run in the order they are being passed
2 participants