Skip to content
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
1 change: 1 addition & 0 deletions tests/docs/quarto-required.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Hello Callout!
format:
html:
quarto-required: "<= 0.0.0"
html+norequire: default
---

This file will not be rendered as it does not respect the quarto version requirement
32 changes: 32 additions & 0 deletions tests/smoke/render/render-required.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,35 @@ testQuartoCmd(
[input],
[printsMessage("ERROR", /does not satisfy version/)]
);

let oldVersionRequirement: string | undefined;
let originalDenoExit: typeof Deno.exit;

testQuartoCmd(
"render",
[input, "--to", "html+norequire"],
[printsMessage("ERROR", /does not meet semver requirement/)],
{
setup: async () => {
// Save current version of QUARTO_VERSION_REQUIREMENT env var and set it to a value that will not be satisfied
oldVersionRequirement = Deno.env.get("QUARTO_VERSION_REQUIREMENT");
Deno.env.set("QUARTO_VERSION_REQUIREMENT", "< 0.0.0");
// Mock Deno.exit to throw an error instead of exiting
// Otherwise we would not check the error assertion
originalDenoExit = Deno.exit;
Deno.exit = (code?: number) => {
throw new Error(`Deno.exit called with code: ${code}`);
};
},
teardown: async () => {
// Restore QUARTO_VERSION_REQUIREMENT
if (oldVersionRequirement) {
Deno.env.set("QUARTO_VERSION_REQUIREMENT", oldVersionRequirement);
} else {
Deno.env.delete("QUARTO_VERSION_REQUIREMENT");
}
// Restore Deno.exit
Deno.exit = originalDenoExit;
},
}
);
Loading