Skip to content

Commit

Permalink
Smaller test
Browse files Browse the repository at this point in the history
  • Loading branch information
cleve-fauna committed Dec 13, 2024
1 parent 641fe76 commit 4b37dac
Showing 1 changed file with 4 additions and 33 deletions.
37 changes: 4 additions & 33 deletions test/local.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ts-check

import { expect } from "chai";
import { fql } from "fauna";
import sinon, { stub } from "sinon";

import { run } from "../src/cli.mjs";
Expand Down Expand Up @@ -124,20 +123,9 @@ Please pass a --hostPort other than '8443'.",
});

[
{
args: "--database Foo",
argv: { database: "Foo" },
},
{
args: "--database Foo --typechecked --protected --priority 1",
argv: {
database: "Foo",
typechecked: true,
protected: true,
priority: 1,
},
},
].forEach(({ args, argv }) => {
"--database Foo",
"--database Foo --typechecked --protected --priority 1",
].forEach((args) => {
it("Creates a database if requested", async () => {
setupCreateContainerMocks();
const { runQuery } = container.resolve("faunaClientV10");
Expand All @@ -148,24 +136,7 @@ Please pass a --hostPort other than '8443'.",
expect(runQuery).to.have.been.calledWith({
secret: "secret",
url: "http://0.0.0.0:8443",
query: fql`
let name = ${argv.database}
let database = Database.byName(name)
let protected = ${argv.protected ?? null}
let typechecked = ${argv.typechecked ?? null}
let priority = ${argv.priority ?? null}
if (database == null) {
Database.create({
name: name,
protected: protected,
typechecked: typechecked,
priority: priority,
})
} else if (protected == database.protected && typechecked == database.typechecked && priority == database.priority) {
database
} else {
abort(database)
}`,
query: sinon.match.any,
options: { format: "decorated" },
});
const written = stderrStream.getWritten();
Expand Down

0 comments on commit 4b37dac

Please sign in to comment.