Tear down databases manually feature request
还没有人认领这个 Issue。
- 主要语言
- Shell
- 星标
- 1
- 派生
- 1
- PR 合并指标
- 30 天内没有已合并 PR
描述
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.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先阅读 pg_tmp.sh 中现有的 stop 命令以及调用它的 Node.js API。使用 Vitest 示例作为预期用法,定义应如何从 createDb 暴露手动 teardown 函数。当调用方可以在测试清理期间调用 teardownDb,并且复用现有的数据库关闭行为时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- node.js, postgresql, shell
- 领域
- api, databases, testing-qa
- Issue 类型
- 功能
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100