Skip to content

Add snapshot support to postgres module#961

Merged
cristianrgreco merged 7 commits intotestcontainers:mainfrom
Nikola-Milovic:feat-module-postgres-snapshotting
Mar 25, 2025
Merged

Add snapshot support to postgres module#961
cristianrgreco merged 7 commits intotestcontainers:mainfrom
Nikola-Milovic:feat-module-postgres-snapshotting

Conversation

@Nikola-Milovic
Copy link
Copy Markdown
Contributor

Added snapshot and restore feature to Postgres module, very closely following the Golang implementation

Closes #952

Summary:

  • ✔️ Snapshot and restore functionality
  • ✔️ Tests
  • ✔️ Docs updated and previewed (copied over from golang)
  • ✔️ Lint & format
  • ❌ Haven't updated the package version

What can be improved:
I utilized comments very heavily, but it really helps with the glance value of the tests, you can very easily identify what is happening, but I can remove them if requested.

Tests:

 ✓ src/postgresql-container.test.ts (10 tests) 27393ms
   ✓ PostgreSqlContainer > should connect and return a query result  2957ms
   ✓ PostgreSqlContainer > should work with database URI  2466ms
   ✓ PostgreSqlContainer > should set database  3059ms
   ✓ PostgreSqlContainer > should set username  2399ms
   ✓ PostgreSqlContainer > should work with restarted container  3013ms
   ✓ PostgreSqlContainer > should allow custom healthcheck  762ms
   ✓ PostgreSqlContainer snapshot and restore > should create and restore from snapshot  3334ms
   ✓ PostgreSqlContainer snapshot and restore > should use custom snapshot name  3314ms
   ✓ PostgreSqlContainer snapshot and restore > should handle multiple snapshots  4100ms
   ✓ PostgreSqlContainer snapshot and restore > should throw an error when trying to snapshot postgres system database  1987ms

 Test Files  1 passed (1)
      Tests  10 passed (10)
   Start at  07:26:23
   Duration  27.81s (transform 167ms, setup 0ms, collect 310ms, tests 27.39s, environment 0ms, prepare 31ms)

 PASS  Waiting for file changes...
       press h to show help, press q to quit

cc @cristianrgreco

Added snapshot and restore feature to postgres module, followed by docs
and appropriate test cases.
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 25, 2025

Deploy Preview for testcontainers-node ready!

Name Link
🔨 Latest commit 547bbcc
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-node/deploys/67e2958e11741e0008149ad6
😎 Deploy Preview https://deploy-preview-961--testcontainers-node.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.

@cristianrgreco cristianrgreco added enhancement New feature or request minor Backward compatible functionality labels Mar 25, 2025
@cristianrgreco
Copy link
Copy Markdown
Collaborator

Thanks @Nikola-Milovic! Just a few nitpicks but overall LGTM

@Nikola-Milovic
Copy link
Copy Markdown
Contributor Author

Also made the js docs more concise

@cristianrgreco cristianrgreco changed the title Feat: Add snapshot support to postgres module Add snapshot support to postgres module Mar 25, 2025
@cristianrgreco cristianrgreco merged commit 17ae9b5 into testcontainers:main Mar 25, 2025
18 checks passed
vaernion pushed a commit to Arbeidstilsynet/brevgen2 that referenced this pull request Dec 3, 2025
….23.0

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [testcontainers](https://github.com/testcontainers/testcontainers-node) | [`10.21.0` -> `10.23.0`](https://renovatebot.com/diffs/npm/testcontainers/10.21.0/10.23.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/testcontainers/10.23.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/testcontainers/10.23.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/testcontainers/10.21.0/10.23.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/testcontainers/10.21.0/10.23.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>testcontainers/testcontainers-node (testcontainers)</summary>

### [`v10.23.0`](https://github.com/testcontainers/testcontainers-node/releases/tag/v10.23.0)

[Compare Source](testcontainers/testcontainers-node@v10.22.0...v10.23.0)

#### Changes

#### 🚀 Features

-   Add snapshot support to postgres module [@&#8203;Nikola-Milovic](https://github.com/Nikola-Milovic) ([#&#8203;961](testcontainers/testcontainers-node#961))

### [`v10.22.0`](https://github.com/testcontainers/testcontainers-node/releases/tag/v10.22.0)

[Compare Source](testcontainers/testcontainers-node@v10.21.0...v10.22.0)

#### Changes

#### 🚀 Features

-   Improve PortCheck logging for distroless images [@&#8203;digital88](https://github.com/digital88) ([#&#8203;954](testcontainers/testcontainers-node#954))
-   Add buildkit support [@&#8203;cristianrgreco](https://github.com/cristianrgreco) ([#&#8203;955](testcontainers/testcontainers-node#955))
-   Add `TESTCONTAINERS_RYUK_VERBOSE` setting [@&#8203;digital88](https://github.com/digital88) ([#&#8203;941](testcontainers/testcontainers-node#941))
-   Update ChromaDB + improve docs and tests [@&#8203;cristianrgreco](https://github.com/cristianrgreco) ([#&#8203;940](testcontainers/testcontainers-node#940))
-   Implement `withAutoRemove` [#&#8203;905](testcontainers/testcontainers-node#905) [@&#8203;digital88](https://github.com/digital88) ([#&#8203;939](testcontainers/testcontainers-node#939))

#### 🐛 Bug Fixes

-   Couchbase: add missing exports and fix sonar suggestions [@&#8203;digital88](https://github.com/digital88) ([#&#8203;942](testcontainers/testcontainers-node#942))

#### 🧹 Maintenance

-   Docs: clarified timeout unit in different places [@&#8203;digital88](https://github.com/digital88) ([#&#8203;958](https://github.com/test...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor Backward compatible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add snapshot support in Postgres module

2 participants