Skip to content

Commit

Permalink
use dev db when secret env set
Browse files Browse the repository at this point in the history
This will allow us to run the github action tests against dev fauna.
Unfortunately github actions services are only supported for linux
runners so if we want to run our extension tests on the other oses we'll
need to use dev from them.
  • Loading branch information
fauna-chase committed Jul 24, 2023
1 parent 5b8d4b5 commit 6fb1c7a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/test/suite/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,35 @@ 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,
secret: "secret",
});
}

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<string>(fql`
if (Database.byName(${name}).exists()) {
Key.where(.database == ${name}).forEach(.delete())
Expand Down

0 comments on commit 6fb1c7a

Please sign in to comment.