diff --git a/src/test/suite/helper.ts b/src/test/suite/helper.ts index 60fbbc8..f129af3 100644 --- a/src/test/suite/helper.ts +++ b/src/test/suite/helper.ts @@ -22,6 +22,14 @@ export async function sleep(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)); } +export function getClient(): Client { + if (process.env.VSCODE_DB_SECRET) { + return getDevDB(process.env.VSCODE_DB_SECRET); + } else { + return getLocalClient(); + } +} + export function getLocalClient(): Client { return new Client({ endpoint: endpoints.local, @@ -29,13 +37,20 @@ export function getLocalClient(): Client { }); } +export function getDevDB(secret: string): Client { + return new Client({ + endpoint: new URL("https://db.dev.faunadb.net"), + secret: secret + }); +} + /** * Returns the fqlx client to use as well as the secret to use to configure the * extension with. */ export const clientWithFreshDB = async (name: string): Promise<[Client, string]> => { - const parentClient = getLocalClient(); + const parentClient = getClient(); const secretQ = await parentClient.query(fql` if (Database.byName(${name}).exists()) { Key.where(.database == ${name}).forEach(.delete())