Skip to content

Commit

Permalink
fix concurrency issue on tests (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamBergamin authored Oct 23, 2023
1 parent 6248db7 commit 949bee3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"tasks": {
"test": "deno fmt --check && deno lint && deno test --allow-read --allow-net --allow-write --allow-run src",
"coverage": "deno test --allow-read --allow-net --allow-write --allow-run --coverage=.coverage src && deno coverage --exclude=fixtures --exclude=test --lcov --output=lcov.info .coverage && deno run --allow-read https://deno.land/x/[email protected]/cli.ts"
"coverage": "rm -rf .coverage && deno test --reporter=dot --allow-read --allow-net --allow-write --allow-run --coverage=.coverage src && deno coverage --exclude=fixtures --exclude=test --lcov --output=lcov.info .coverage && deno run --allow-read https://deno.land/x/[email protected]/cli.ts"
},
"lock": false
}
45 changes: 24 additions & 21 deletions src/tests/get_trigger_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { assertRejects, assertStringIncludes } from "../dev_deps.ts";

Deno.test("get-trigger hook", async (t) => {
await t.step("getTrigger function", async (tt) => {
await tt.step("should throw if no source CLI flag provided", () => {
assertRejects(
() => getTrigger([]),
await tt.step("should throw if no source CLI flag provided", async () => {
await assertRejects(
async () => await getTrigger([]),
Error,
"source path needs to be defined",
);
});

await tt.step("should throw if provided source is not a file", () => {
assertRejects(
() => getTrigger(["--source", "src"]),
await tt.step("should throw if provided source is not a file", async () => {
await assertRejects(
async () => await getTrigger(["--source", "src"]),
Error,
"source is not a valid file",
);
Expand All @@ -35,24 +35,27 @@ Deno.test("get-trigger hook", async (t) => {
assertStringIncludes(json.name, "greeting");
});

await tt.step("should throw if provided .ts has no default export", () => {
assertRejects(
() =>
getTrigger([
"--source",
"src/tests/fixtures/triggers/no_default_export_trigger.ts",
]),
Error,
"no default export",
);
});
await tt.step(
"should throw if provided .ts has no default export",
async () => {
await assertRejects(
async () =>
await getTrigger([
"--source",
"src/tests/fixtures/triggers/no_default_export_trigger.ts",
]),
Error,
"no default export",
);
},
);

await tt.step(
"should throw if provided .ts has a non-object default export",
() => {
assertRejects(
() =>
getTrigger([
async () => {
await assertRejects(
async () =>
await getTrigger([
"--source",
"src/tests/fixtures/triggers/non_object_trigger.ts",
]),
Expand Down

0 comments on commit 949bee3

Please sign in to comment.