Skip to content

Commit 2961ba1

Browse files
authored
Merge pull request #17 from shelfio/feature/Stop-cluster-after-fail
Stop cluster and clean up files after fail
2 parents 93f8a8d + b635ac2 commit 2961ba1

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shelf/postgres-local",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "Run Postgres locally",
55
"keywords": [
66
"postgres",

src/index.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ import postgres from 'postgres';
44
import {start, stop} from '.';
55

66
describe('#postgres', () => {
7+
// The order of tests matters here
8+
// since plugin should clean up files and rerun correctly even after error occurred after start
9+
10+
it('should stop postgres and clear files locally if error occurred during start', async () => {
11+
try {
12+
await start({
13+
version: 12,
14+
debugMode: true,
15+
seedPath: `${cwd()}/src/notExists.sql`,
16+
});
17+
} catch (e) {
18+
// @ts-ignore
19+
expect(e.name).toEqual('Error');
20+
}
21+
});
22+
723
it('should start postgres locally', async () => {
824
expect.assertions(2);
925

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export async function start(options: {
4747
return url;
4848
} catch (e) {
4949
console.error(e);
50+
stop(options);
5051
throw e;
5152
}
5253
}

0 commit comments

Comments
 (0)