From d41b27f43335cfb1a8ff49aeb121f992332429cf Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 12 Aug 2021 15:37:30 +0200 Subject: Cleaned up the settings implementation & renamed base_dir project-wide to git_dir --- test/unit/blob.unit.test.ts | 4 ++-- test/unit/branch.unit.test.ts | 8 ++++---- test/unit/commit.unit.test.ts | 2 +- test/unit/diff.unit.test.ts | 2 +- test/unit/misc.unit.test.ts | 8 ++++---- test/unit/patch.unit.test.ts | 6 +++--- test/unit/repository.unit.test.ts | 12 ++++++------ test/unit/tag.unit.test.ts | 4 ++-- test/unit/tree.unit.test.ts | 4 ++-- test/unit/tree_entry.unit.test.ts | 8 ++++---- 10 files changed, 29 insertions(+), 29 deletions(-) (limited to 'test/unit') diff --git a/test/unit/blob.unit.test.ts b/test/unit/blob.unit.test.ts index 1771255..308245a 100644 --- a/test/unit/blob.unit.test.ts +++ b/test/unit/blob.unit.test.ts @@ -10,7 +10,7 @@ describe("Blob", () => { it("Should the get a blob from a path in a tree", async() => { expect.assertions(2); - const tree = await Tree.ofRepository(await Repository.open(env.BASE_DIR, env.AVAIL_REPO)); + const tree = await Tree.ofRepository(await Repository.open(env.GIT_DIR, env.AVAIL_REPO)); const blob = await Blob.fromPath(tree, "packages/client/src/main.ts"); expect(blob).toBeDefined(); @@ -22,7 +22,7 @@ describe("Blob", () => { let blob: Blob; beforeAll(async() => { - const tree = await Tree.ofRepository(await Repository.open(env.BASE_DIR, env.AVAIL_REPO)); + const tree = await Tree.ofRepository(await Repository.open(env.GIT_DIR, env.AVAIL_REPO)); blob = await Blob.fromPath(tree, "packages/client/src/main.ts"); }); diff --git a/test/unit/branch.unit.test.ts b/test/unit/branch.unit.test.ts index 3f067a8..cf37fb5 100644 --- a/test/unit/branch.unit.test.ts +++ b/test/unit/branch.unit.test.ts @@ -9,7 +9,7 @@ describe("Branch", () => { it("Should lookup a branch", async() => { expect.assertions(2); - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); const branch = await Branch.lookup(repository, "master"); expect(branch).toBeDefined(); @@ -19,7 +19,7 @@ describe("Branch", () => { it("Should lookup if an existent branch exists and respond true", async() => { expect.assertions(2); - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); const branch_exists = await Branch.lookupExists(repository.ng_repository, "master"); expect(branch_exists).toBeDefined(); @@ -29,7 +29,7 @@ describe("Branch", () => { it("Should lookup if an nonexistent branch exists and respond false", async() => { expect.assertions(2); - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); const branch_exists = await Branch.lookupExists(repository.ng_repository, "wubbalubbadubdub"); expect(branch_exists).toBeDefined(); @@ -41,7 +41,7 @@ describe("Branch", () => { let branch: Branch; beforeAll(async() => { - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); branch = await Branch.lookup(repository, "master"); }); diff --git a/test/unit/commit.unit.test.ts b/test/unit/commit.unit.test.ts index e9e0e0d..21c04db 100644 --- a/test/unit/commit.unit.test.ts +++ b/test/unit/commit.unit.test.ts @@ -10,7 +10,7 @@ describe("Commit", () => { let repository: Repository; beforeAll(async() => { - repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); }); describe("Class methods", () => { diff --git a/test/unit/diff.unit.test.ts b/test/unit/diff.unit.test.ts index ed4061b..2f88d29 100644 --- a/test/unit/diff.unit.test.ts +++ b/test/unit/diff.unit.test.ts @@ -9,7 +9,7 @@ describe("Diff", () => { let diff: Diff; beforeAll(async() => { - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); diff = await (await repository.head()).diff(); }); diff --git a/test/unit/misc.unit.test.ts b/test/unit/misc.unit.test.ts index c45d8ba..38c69fd 100644 --- a/test/unit/misc.unit.test.ts +++ b/test/unit/misc.unit.test.ts @@ -44,7 +44,7 @@ describe("Miscellaneous functions", () => { it("Should return the content of a file in a bare git repository", async() => { expect.assertions(2); - const content = await getFile(env.BASE_DIR, env.AVAIL_REPO, "description"); + const content = await getFile(env.GIT_DIR, env.AVAIL_REPO, "description"); expect(content).toBeDefined(); expect(content).toEqual("Unnamed repository; edit this file 'description' to name the repository."); @@ -53,7 +53,7 @@ describe("Miscellaneous functions", () => { it("Should fail to return the content of a nonexistent file in a bare repository", async() => { expect.assertions(1); - await expect(getFile(env.BASE_DIR, env.AVAIL_REPO, "myselfasteem")).rejects.toBeInstanceOf(BaseError); + await expect(getFile(env.GIT_DIR, env.AVAIL_REPO, "myselfasteem")).rejects.toBeInstanceOf(BaseError); }); }); @@ -61,7 +61,7 @@ describe("Miscellaneous functions", () => { it("Should return the content of a directory", async() => { expect.assertions(3); - const dir = await getDirectory(`${env.BASE_DIR}/${env.AVAIL_REPO}/refs`); + const dir = await getDirectory(`${env.GIT_DIR}/${env.AVAIL_REPO}/refs`); expect(dir).toBeDefined(); expect(dir).toContain("heads"); @@ -71,7 +71,7 @@ describe("Miscellaneous functions", () => { it("Should fail to return the content of a nonexistent directory", async() => { expect.assertions(1); - await expect(getDirectory(`${env.BASE_DIR}/${env.AVAIL_REPO}/something`)).rejects.toBeInstanceOf(BaseError); + await expect(getDirectory(`${env.GIT_DIR}/${env.AVAIL_REPO}/something`)).rejects.toBeInstanceOf(BaseError); }); }); }); \ No newline at end of file diff --git a/test/unit/patch.unit.test.ts b/test/unit/patch.unit.test.ts index 3197059..d011825 100644 --- a/test/unit/patch.unit.test.ts +++ b/test/unit/patch.unit.test.ts @@ -10,7 +10,7 @@ describe("Patch", () => { it("Should get a patch from a diff", async() => { expect.assertions(2); - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); const commit = await Commit.lookup(repository, "d856031c58e26992f3e0a481084a190a50b0bcf7"); const patch = await Patch.fromDiff(await commit.diff(), 1); @@ -22,7 +22,7 @@ describe("Patch", () => { it("Should get all patches from a diff", async() => { expect.hasAssertions(); - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); const commit = await Commit.lookup(repository, "7b3292af22a0496007e974b65cd2e34521c9c429"); const patches = await Patch.allFromDiff(await commit.diff()); @@ -42,7 +42,7 @@ describe("Patch", () => { let patch: Patch; beforeAll(async() => { - repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); const commit = await Commit.lookup(repository, "7b3292af22a0496007e974b65cd2e34521c9c429"); patch = await Patch.fromDiff(await commit.diff(), 4); diff --git a/test/unit/repository.unit.test.ts b/test/unit/repository.unit.test.ts index 66e32d4..b3d9a2d 100644 --- a/test/unit/repository.unit.test.ts +++ b/test/unit/repository.unit.test.ts @@ -9,7 +9,7 @@ import { BaseError } from "server/src/git/error"; const env = process.env as EnvironmentVariables; function expectRepositoryProperties(repository: Repository) { - expect(repository).toHaveProperty("base_dir"); + expect(repository).toHaveProperty("git_dir"); expect(repository).toHaveProperty("description"); expect(repository).toHaveProperty("name"); expect(repository).toHaveProperty("name.full"); @@ -22,7 +22,7 @@ describe("Repository", () => { it("Should open a repository", async() => { expect.assertions(8); - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); expect(repository).toBeDefined(); expect(repository).toBeInstanceOf(Repository); @@ -33,19 +33,19 @@ describe("Repository", () => { it("Should fail to open a nonexistant repository", async() => { expect.assertions(1); - await expect(Repository.open(env.BASE_DIR, env.UNAVAIL_REPO)).rejects.toBeInstanceOf(BaseError); + await expect(Repository.open(env.GIT_DIR, env.UNAVAIL_REPO)).rejects.toBeInstanceOf(BaseError); }); it("Should fail to open a repository with a nonexistant branch", async() => { expect.assertions(1); - await expect(Repository.open(env.BASE_DIR, env.AVAIL_REPO, "wubbalubbadubdub")).rejects.toBeInstanceOf(BaseError); + await expect(Repository.open(env.GIT_DIR, env.AVAIL_REPO, "wubbalubbadubdub")).rejects.toBeInstanceOf(BaseError); }); it("Should open all repositories", async() => { expect.hasAssertions(); - const all_repositories = await Repository.openAll(env.BASE_DIR); + const all_repositories = await Repository.openAll(env.GIT_DIR); expect(all_repositories).toBeDefined(); @@ -62,7 +62,7 @@ describe("Repository", () => { let repository: Repository; beforeAll(async() => { - repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); }); it("Should get the description", async() => { diff --git a/test/unit/tag.unit.test.ts b/test/unit/tag.unit.test.ts index 8321092..76abc33 100644 --- a/test/unit/tag.unit.test.ts +++ b/test/unit/tag.unit.test.ts @@ -9,7 +9,7 @@ describe("Tag", () => { it("Should lookup a tag", async() => { expect.assertions(2); - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); const tag = await Tag.lookup(repository, "1.2"); @@ -22,7 +22,7 @@ describe("Tag", () => { let tag: Tag; beforeAll(async() => { - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); tag = await Tag.lookup(repository, "1.2"); }); diff --git a/test/unit/tree.unit.test.ts b/test/unit/tree.unit.test.ts index 1cbc85a..1754e7a 100644 --- a/test/unit/tree.unit.test.ts +++ b/test/unit/tree.unit.test.ts @@ -12,7 +12,7 @@ describe("Tree", () => { it("Should get the tree of a repository", async() => { expect.assertions(2); - const tree = await Tree.ofRepository(await Repository.open(env.BASE_DIR, env.AVAIL_REPO)); + const tree = await Tree.ofRepository(await Repository.open(env.GIT_DIR, env.AVAIL_REPO)); expect(tree).toBeDefined(); expect(tree).toBeInstanceOf(Tree); @@ -23,7 +23,7 @@ describe("Tree", () => { let tree: Tree; beforeAll(async() => { - tree = await Tree.ofRepository(await Repository.open(env.BASE_DIR, env.AVAIL_REPO)); + tree = await Tree.ofRepository(await Repository.open(env.GIT_DIR, env.AVAIL_REPO)); }); it("Should get the entries", () => { diff --git a/test/unit/tree_entry.unit.test.ts b/test/unit/tree_entry.unit.test.ts index de270c5..ca4fbc6 100644 --- a/test/unit/tree_entry.unit.test.ts +++ b/test/unit/tree_entry.unit.test.ts @@ -13,7 +13,7 @@ describe("Tree entry", () => { let tree_entry: BaseTreeEntry; beforeAll(async() => { - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); const tree = await repository.tree(); tree_entry = tree.entries()[0]; }); @@ -63,7 +63,7 @@ describe("Tree entry", () => { let tree_entry: BaseTreeEntry; beforeAll(async() => { - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); const tree = await repository.tree(); const entry = tree.entries().find(entry => entry.path === "test"); if(!entry) { @@ -91,7 +91,7 @@ describe("Tree entry", () => { let tree_entry: BaseTreeEntry; beforeAll(async() => { - const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO); + const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO); const tree = await repository.tree(); tree_entry = tree.entries()[0]; }); @@ -108,4 +108,4 @@ describe("Tree entry", () => { }); }); }); -}); +}); \ No newline at end of file -- cgit v1.2.3-18-g5258