Tear down databases manually feature request

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

Nobody has claimed this yet.

Assessment

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

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.

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 a possible implementation of this would be:

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.

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

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.

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.