diff options
author | HampusM <hampus@hampusmat.com> | 2021-07-27 16:51:54 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2021-07-27 16:51:54 +0200 |
commit | 055a58e79fb225978d64a3c8e3e25377cc2a5ece (patch) | |
tree | 8c37c249b93dfeb507afbf6b156955c96ad3bd49 /test/setup.ts | |
parent | fa44d81b658024685e0496150d66a51f2f5fda8c (diff) |
Added new unit tests & the test setup script uses Nodegit instead of exec
Diffstat (limited to 'test/setup.ts')
-rw-r--r-- | test/setup.ts | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/test/setup.ts b/test/setup.ts index 89eeead..d446296 100644 --- a/test/setup.ts +++ b/test/setup.ts @@ -1,10 +1,8 @@ -import { access, mkdir, remove } from "fs-extra"; -import { promisify } from "util"; -import { exec } from "child_process"; +import { access, mkdir, remove, writeFile } from "fs-extra"; import { config } from "dotenv"; import { EnvironmentVariables } from "./util"; +import { Clone } from "nodegit"; -const promiseExec = promisify(exec); config({ path: "test/test.env" }); const env = process.env as EnvironmentVariables; @@ -20,15 +18,14 @@ export default async function(): Promise<void> { await mkdir(env.BASE_DIR); - const git_clone = await promiseExec(`git clone -q --bare ${env.AVAIL_REPO_URL} ${env.BASE_DIR}/${env.AVAIL_REPO}`); + const repository = await Clone.clone(env.AVAIL_REPO_URL, `${env.BASE_DIR}/${env.AVAIL_REPO}`, { bare: 1 }); - if(git_clone.stderr) { - throw(git_clone.stderr); - } + const config = await repository.config(); + await config.setString("user.name", "BobDylan"); + await config.setString("user.email", "bob@example.com"); - const git_fetch = await promiseExec(`git -C ${env.BASE_DIR}/${env.AVAIL_REPO} fetch -q --all`); + await repository.fetchAll(); + await repository.createTag((await repository.getMasterCommit()).id(), "1.2", "Fixed stuff"); - if(git_fetch.stderr) { - throw(git_fetch.stderr); - } + await writeFile(`${env.BASE_DIR}/${env.AVAIL_REPO}/owner`, "Bob"); }
\ No newline at end of file |