Skip to content

Commit

Permalink
Failure mode tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cleve-fauna committed Dec 13, 2024
1 parent 48f2625 commit ebb3b8f
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions test/local.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import sinon, { stub } from "sinon";
import { run } from "../src/cli.mjs";
import { setupTestContainer } from "../src/config/setup-test-container.mjs";
import { f } from "./helpers.mjs";
import { AbortError } from "fauna";

describe("ensureContainerRunning", () => {
let container,
Expand Down Expand Up @@ -144,11 +145,26 @@ Please pass a --hostPort other than '8443'.",
});
});

[
"--typechecked",
"--protected",
"--priority 1",
].forEach((args) => {
it("Exits with an expected error if teh query aborts", async () => {
setupCreateContainerMocks();
const { runQuery } = container.resolve("faunaClientV10");
runQuery.rejects(new AbortError({ error: { abort: "Taco" }}));
try {
await run(`local --no-color --database Foo`, container);
} catch (_) {}
expect(runQuery).to.have.been.calledWith({
secret: "secret",
url: "http://0.0.0.0:8443",
query: sinon.match.any,
options: { format: "decorated" },
});
const written = stderrStream.getWritten();
expect(written).to.contain('Taco');
expect(written).not.to.contain("fauna local");
expect(written).not.to.contain("An unexpected");
});

["--typechecked", "--protected", "--priority 1"].forEach((args) => {
it("Rejects invalid create database args", async () => {
setupCreateContainerMocks();
const { runQuery } = container.resolve("faunaClientV10");
Expand Down

0 comments on commit ebb3b8f

Please sign in to comment.