From ddcf71225226bc0929d5c6d609b13ff0489e5b94 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 14 Aug 2021 22:28:17 +0200 Subject: Revamped backend error handling & improved imports in tests --- test/unit/blob.unit.test.ts | 6 +++--- test/unit/branch.unit.test.ts | 4 ++-- test/unit/misc.unit.test.ts | 6 +++--- test/unit/patch.unit.test.ts | 6 +++--- test/unit/repository.unit.test.ts | 6 +++--- test/unit/tag.unit.test.ts | 4 ++-- test/unit/tree.unit.test.ts | 4 ++-- test/unit/tree_entry.unit.test.ts | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) (limited to 'test/unit') diff --git a/test/unit/blob.unit.test.ts b/test/unit/blob.unit.test.ts index 308245a..d0c4853 100644 --- a/test/unit/blob.unit.test.ts +++ b/test/unit/blob.unit.test.ts @@ -1,7 +1,7 @@ -import { Repository } from "../../packages/server/src/git/repository"; -import { Tree } from "../../packages/server/src/git/tree"; +import { Repository } from "server/src/git/repository"; +import { Tree } from "server/src/git/tree"; import { EnvironmentVariables } from "../util"; -import { Blob } from "../../packages/server/src/git/blob"; +import { Blob } from "server/src/git/blob"; const env = process.env as EnvironmentVariables; diff --git a/test/unit/branch.unit.test.ts b/test/unit/branch.unit.test.ts index cf37fb5..5cab4b5 100644 --- a/test/unit/branch.unit.test.ts +++ b/test/unit/branch.unit.test.ts @@ -1,5 +1,5 @@ -import { Branch } from "../../packages/server/src/git/branch"; -import { Repository } from "../../packages/server/src/git/repository"; +import { Branch } from "server/src/git/branch"; +import { Repository } from "server/src/git/repository"; import { EnvironmentVariables } from "../util"; const env = process.env as EnvironmentVariables; diff --git a/test/unit/misc.unit.test.ts b/test/unit/misc.unit.test.ts index 38c69fd..d3d793a 100644 --- a/test/unit/misc.unit.test.ts +++ b/test/unit/misc.unit.test.ts @@ -1,5 +1,5 @@ import { findAsync, getDirectory, getFile } from "server/src/git/misc"; -import { BaseError } from "server/src/git/error"; +import { ServerError } from "server/src/git/error"; import { EnvironmentVariables } from "../util"; const env = process.env as EnvironmentVariables; @@ -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.GIT_DIR, env.AVAIL_REPO, "myselfasteem")).rejects.toBeInstanceOf(BaseError); + await expect(getFile(env.GIT_DIR, env.AVAIL_REPO, "myselfasteem")).rejects.toBeInstanceOf(ServerError); }); }); @@ -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.GIT_DIR}/${env.AVAIL_REPO}/something`)).rejects.toBeInstanceOf(BaseError); + await expect(getDirectory(`${env.GIT_DIR}/${env.AVAIL_REPO}/something`)).rejects.toBeInstanceOf(ServerError); }); }); }); \ No newline at end of file diff --git a/test/unit/patch.unit.test.ts b/test/unit/patch.unit.test.ts index d011825..ed67a28 100644 --- a/test/unit/patch.unit.test.ts +++ b/test/unit/patch.unit.test.ts @@ -1,6 +1,6 @@ -import { Commit } from "../../packages/server/src/git/commit"; -import { Patch } from "../../packages/server/src/git/patch"; -import { Repository } from "../../packages/server/src/git/repository"; +import { Commit } from "server/src/git/commit"; +import { Patch } from "server/src/git/patch"; +import { Repository } from "server/src/git/repository"; import { EnvironmentVariables } from "../util"; const env = process.env as EnvironmentVariables; diff --git a/test/unit/repository.unit.test.ts b/test/unit/repository.unit.test.ts index b3d9a2d..752cd59 100644 --- a/test/unit/repository.unit.test.ts +++ b/test/unit/repository.unit.test.ts @@ -4,7 +4,7 @@ import { Tree } from "server/src/git/tree"; import { Branch } from "server/src/git/branch"; import { Tag } from "server/src/git/tag"; import { EnvironmentVariables, expectCommitProperties } from "../util"; -import { BaseError } from "server/src/git/error"; +import { ServerError } from "server/src/git/error"; const env = process.env as EnvironmentVariables; @@ -33,13 +33,13 @@ describe("Repository", () => { it("Should fail to open a nonexistant repository", async() => { expect.assertions(1); - await expect(Repository.open(env.GIT_DIR, env.UNAVAIL_REPO)).rejects.toBeInstanceOf(BaseError); + await expect(Repository.open(env.GIT_DIR, env.UNAVAIL_REPO)).rejects.toBeInstanceOf(ServerError); }); it("Should fail to open a repository with a nonexistant branch", async() => { expect.assertions(1); - await expect(Repository.open(env.GIT_DIR, env.AVAIL_REPO, "wubbalubbadubdub")).rejects.toBeInstanceOf(BaseError); + await expect(Repository.open(env.GIT_DIR, env.AVAIL_REPO, "wubbalubbadubdub")).rejects.toBeInstanceOf(ServerError); }); it("Should open all repositories", async() => { diff --git a/test/unit/tag.unit.test.ts b/test/unit/tag.unit.test.ts index 76abc33..dfeedfe 100644 --- a/test/unit/tag.unit.test.ts +++ b/test/unit/tag.unit.test.ts @@ -1,5 +1,5 @@ -import { Repository } from "../../packages/server/src/git/repository"; -import { Tag } from "../../packages/server/src/git/tag"; +import { Repository } from "server/src/git/repository"; +import { Tag } from "server/src/git/tag"; import { EnvironmentVariables } from "../util"; const env = process.env as EnvironmentVariables; diff --git a/test/unit/tree.unit.test.ts b/test/unit/tree.unit.test.ts index 1754e7a..737aceb 100644 --- a/test/unit/tree.unit.test.ts +++ b/test/unit/tree.unit.test.ts @@ -1,7 +1,7 @@ import { Repository } from "server/src/git/repository"; import { Tree } from "server/src/git/tree"; import { BaseTreeEntry, BlobTreeEntry, TreeEntry } from "server/src/git/tree_entry"; -import { BaseError } from "server/src/git/error"; +import { ServerError } from "server/src/git/error"; import { EnvironmentVariables } from "../util"; import { extract, Headers } from "tar-stream"; @@ -51,7 +51,7 @@ describe("Tree", () => { it("Should fail to return the entry of a nonexistent path", async() => { expect.assertions(1); - await expect(tree.find("dependencies/libstd++")).rejects.toBeInstanceOf(BaseError); + await expect(tree.find("dependencies/libstd++")).rejects.toBeInstanceOf(ServerError); }); it("Should find out if an existent path exists and return true", async() => { diff --git a/test/unit/tree_entry.unit.test.ts b/test/unit/tree_entry.unit.test.ts index ca4fbc6..5a9e87a 100644 --- a/test/unit/tree_entry.unit.test.ts +++ b/test/unit/tree_entry.unit.test.ts @@ -3,7 +3,7 @@ import { Repository } from "server/src/git/repository"; import { EnvironmentVariables } from "../util"; import { Commit } from "server/src/git/commit"; import { Tree } from "server/src/git/tree"; -import { Blob } from "../../packages/server/src/git/blob"; +import { Blob } from "server/src/git/blob"; const env = process.env as EnvironmentVariables; -- cgit v1.2.3-18-g5258