forked from storj-archived/bridge
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): move cleanup to global setup & teardown
- Loading branch information
Showing
5 changed files
with
38 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { config as loadEnv } from 'dotenv' | ||
import { MongoClient } from 'mongodb'; | ||
declare var globalThis: any | ||
|
||
export default async () => { | ||
loadEnv(); | ||
const url = process.env.inxtbridge_storage__mongoUrl; | ||
if (!url) throw new Error('Missing mongo url'); | ||
if (!url.includes('test')) { | ||
throw new Error("For caution test database must include test in it's name"); | ||
} | ||
const client = new MongoClient(url); | ||
await client.connect(); | ||
|
||
const db = client.db(); | ||
await Promise.all([ | ||
db.collection('users').deleteMany({}), | ||
db.collection('buckets').deleteMany({}) | ||
]); | ||
|
||
globalThis.mongoClient = client; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
import { type MongoClient } from 'mongodb' | ||
declare var globalThis: any | ||
|
||
export default async () => { | ||
|
||
const client = globalThis.mongoClient as MongoClient; | ||
const db = client.db(); | ||
|
||
await Promise.all([ | ||
db.collection('users').deleteMany({}), | ||
db.collection('buckets').deleteMany({}) | ||
]); | ||
|
||
await client.close(); | ||
|
||
process.emit('SIGINT') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters