diff options
author | HampusM <hampus@hampusmat.com> | 2021-07-23 14:17:35 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2021-07-23 14:17:35 +0200 |
commit | 929c1ee1182e18496a8cfdc56cde4a008e59a5c6 (patch) | |
tree | 8c23e8c1c91555336ecbb02e267be11c7b3075c2 /test | |
parent | d70c44f84ff347685841101fa589cf7ef2312bf8 (diff) |
The test setup script uses the env variables type & fetches refs
Diffstat (limited to 'test')
-rw-r--r-- | test/setup.ts | 17 | ||||
-rw-r--r-- | test/util.ts | 1 |
2 files changed, 14 insertions, 4 deletions
diff --git a/test/setup.ts b/test/setup.ts index 3eaa5e7..50c8754 100644 --- a/test/setup.ts +++ b/test/setup.ts @@ -2,24 +2,33 @@ import { access, mkdir, remove } from "fs-extra"; import { promisify } from "util"; import { exec } from "child_process"; import { config } from "dotenv"; +import { EnvironmentVariables } from "./util"; const promiseExec = promisify(exec); config({ path: "test/test.env" }); +const env = process.env as EnvironmentVariables; + export default async function init() { - const can_access = await access(process.env.BASE_DIR) + const can_access = await access(env.BASE_DIR) .then(() => true) .catch(() => false); if(can_access) { - await remove(process.env.BASE_DIR); + await remove(env.BASE_DIR); } - await mkdir(process.env.BASE_DIR); + await mkdir(env.BASE_DIR); - const git_clone = await promiseExec(`git clone -q --bare ${process.env.AVAIL_REPO_URL} ${process.env.BASE_DIR}/${process.env.AVAIL_REPO}`); + const git_clone = await promiseExec(`git clone -q --bare ${env.AVAIL_REPO_URL} ${env.BASE_DIR}/${env.AVAIL_REPO}`); if(git_clone.stderr) { throw(git_clone.stderr); } + + const git_fetch = await promiseExec(`git -C ${env.BASE_DIR}/${env.AVAIL_REPO} fetch -q --all`); + + if(git_fetch.stderr) { + throw(git_fetch.stderr); + } }
\ No newline at end of file diff --git a/test/util.ts b/test/util.ts index 50611d6..6cc5cbc 100644 --- a/test/util.ts +++ b/test/util.ts @@ -3,6 +3,7 @@ import { Commit } from "server/src/git/commit"; export type EnvironmentVariables = { BASE_DIR: string, AVAIL_REPO: string, + AVAIL_REPO_URL: string, UNAVAIL_REPO: string, AVAIL_OBJECT: string, UNAVAIL_OBJECT: string, |