Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] concurrency issue in tests #72

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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