LinusU / LinusU/node-pg-tmp

Tear down databases manually feature request

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
1
Forks
1
PR merge metrics
No merged PRs in 30d

Description

I think a feature that can be added to this library would be to tear down databases manually.

A use case for this would be to do this in the "tear-down" section in testing frameworks. For example, in [vitest](https://vitest.dev/) a possible implementation of this would be:

```ts
import {describe, test, beforeAll} from "vitest";
import createDb from "pg-tmp";

describe("Database test", () => {
beforeAll(async () => {
const { teardownDb } = await createDb();
// return cleanup function
return async () => {
await teardownDb();
};
});

test("specific database tests", () => {
// tests with the database.
});
});
```

This should be easy to implement using the "stop" command already implemented in `pg_tmp.sh`.

I'd be up to make a PR myself, but I figured I'd get permission first & so forth.

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start by reading the existing stop command in pg_tmp.sh and the Node.js API that invokes it. Define how the manual teardown function should be exposed from createDb, using the Vitest example as the intended usage. Done means callers can invoke teardownDb during test cleanup and the existing database shutdown behavior is reused.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, postgresql, shell
Domain
api, databases, testing-qa
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.