Skip to content

Commit

Permalink
Merge branch 'main' into fe-6286-retry-options
Browse files Browse the repository at this point in the history
  • Loading branch information
ptpaterson authored Feb 4, 2025
2 parents e5a95c3 + 37118a4 commit 8e1ec8b
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 54 deletions.
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ test-results.xml
/test/test-homedir

# default fauna config file names
fauna.config.yaml,
fauna.config.yml,
fauna.config.json,
.fauna.config.yaml,
.fauna.config.yml,
.fauna.config.json,
fauna.config.yaml
fauna.config.yml
fauna.config.json
.fauna.config.yaml
.fauna.config.yml
.fauna.config.json
7 changes: 1 addition & 6 deletions src/commands/schema/abandon.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@ async function doAbandon(argv) {
const secret = await getSecret(argv);

if (!argv.input) {
const params = new URLSearchParams({
force: "true", // Just abandon, don't pass a schema version through.
});

await makeFaunaRequest({
argv,
path: "/schema/1/staged/abandon",
params,
method: "POST",
secret,
});
logger.stdout("Schema has been abandoned.");
} else {
// Show status to confirm.
const params = new URLSearchParams({ diff: "true" });
const params = new URLSearchParams({ format: "semantic" });

const response = await makeFaunaRequest({
argv,
Expand Down
7 changes: 1 addition & 6 deletions src/commands/schema/commit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,17 @@ async function doCommit(argv) {
const secret = await getSecret(argv);

if (!argv.input) {
const params = new URLSearchParams({
force: "true", // Just commit, don't pass a schema version through.
});

await makeFaunaRequest({
argv,
path: "/schema/1/staged/commit",
params,
method: "POST",
secret,
});

logger.stdout("Schema has been committed");
} else {
// Show status to confirm.
const params = new URLSearchParams({ diff: "true" });
const params = new URLSearchParams({ format: "semantic" });

const response = await makeFaunaRequest({
argv,
Expand Down
10 changes: 4 additions & 6 deletions src/commands/schema/diff.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,22 @@ function parseTarget(argv) {
function buildStatusParams(argv) {
const params = new URLSearchParams({});
const [, target] = parseTarget(argv);
const diffKind = argv.text ? "textual" : "semantic";
const format = argv.text ? "textual" : "semantic";

if (target === "staged") params.set("diff", diffKind);
if (target === "staged") params.set("format", format);

return params;
}

function buildValidateParams(argv, version) {
const [source] = parseTarget(argv);
const diffKind = argv.text ? "textual" : "semantic";
const format = argv.text ? "textual" : "semantic";
const params = new URLSearchParams({
diff: diffKind,
format,
staged: String(source === "staged"),
});
if (version) {
params.set("version", version);
} else {
params.set("force", "true");
}

return params;
Expand Down
1 change: 0 additions & 1 deletion src/commands/schema/push.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export async function pushSchema(argv) {
);
} else if (!argv.input) {
const params = new URLSearchParams({
force: "true",
staged: argv.active ? "false" : "true",
});

Expand Down
13 changes: 5 additions & 8 deletions test/commands/local.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,11 @@ Please pass a --host-port other than '8443'.",
await run(`local --no-color ${args}`, container);

expect(gatherFSL).to.have.been.calledWith("bar");
expect(fetch).to.have.been.calledWith(
`${baseUrl}/update?force=true&staged=false`,
{
method: "POST",
headers: { AUTHORIZATION: "Bearer secret:Foo:admin" },
body: reformatFSL(fsl),
},
);
expect(fetch).to.have.been.calledWith(`${baseUrl}/update?staged=false`, {
method: "POST",
headers: { AUTHORIZATION: "Bearer secret:Foo:admin" },
body: reformatFSL(fsl),
});
const written = stderrStream.getWritten();
expect(written).to.contain(
"[CreateDatabaseSchema] Schema for database 'Foo' created from directory './bar'.",
Expand Down
17 changes: 13 additions & 4 deletions test/commands/schema/abandon.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("schema abandon", function () {

expect(fetch).to.have.been.calledOnce;
expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/abandon", { force: "true" }),
buildUrl("/schema/1/staged/abandon"),
{ ...commonFetchParams, method: "POST" },
);
expect(logger.stdout).to.have.been.calledWith("Schema has been abandoned.");
Expand All @@ -65,7 +65,10 @@ describe("schema abandon", function () {
await run(`schema abandon --secret "secret"`, container);

expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
buildUrl("/schema/1/staged/status", {
format: "semantic",
color: "ansi",
}),
{ ...commonFetchParams, method: "GET" },
);
expect(fetch).to.have.been.calledWith(
Expand Down Expand Up @@ -93,7 +96,10 @@ describe("schema abandon", function () {
expect(logger.stderr).to.have.been.calledWith(message);

expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
buildUrl("/schema/1/staged/status", {
format: "semantic",
color: "ansi",
}),
{ ...commonFetchParams, method: "GET" },
);
});
Expand All @@ -117,7 +123,10 @@ describe("schema abandon", function () {

expect(fetch).to.have.been.calledOnce;
expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
buildUrl("/schema/1/staged/status", {
format: "semantic",
color: "ansi",
}),
{ ...commonFetchParams, method: "GET" },
);
expect(logger.stdout).to.have.been.calledWith("Abandon cancelled.");
Expand Down
28 changes: 20 additions & 8 deletions test/commands/schema/commit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ describe("schema commit", function () {
await run(`schema commit --secret "secret"`, container);

expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
buildUrl("/schema/1/staged/status", {
format: "semantic",
color: "ansi",
}),
{ ...commonFetchParams, method: "GET" },
);
expect(fetch).to.have.been.calledWith(
Expand All @@ -62,10 +65,10 @@ describe("schema commit", function () {
await run(`schema commit --secret "secret" --no-input`, container);

expect(fetch).to.have.been.calledOnce;
expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/commit", { force: "true" }),
{ ...commonFetchParams, method: "POST" },
);
expect(fetch).to.have.been.calledWith(buildUrl("/schema/1/staged/commit"), {
...commonFetchParams,
method: "POST",
});
expect(logger.stdout).to.have.been.calledWith("Schema has been committed");
expect(logger.stderr).to.not.have.been.called;
expect(confirm).to.not.have.been.called;
Expand All @@ -81,7 +84,10 @@ describe("schema commit", function () {
expect(error).to.have.property("code", 1);
expect(fetch).to.have.been.calledOnce;
expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
buildUrl("/schema/1/staged/status", {
format: "semantic",
color: "ansi",
}),
{ ...commonFetchParams, method: "GET" },
);
expect(logger.stdout).to.not.have.been.called;
Expand All @@ -100,7 +106,10 @@ describe("schema commit", function () {
expect(error).to.have.property("code", 1);
expect(fetch).to.have.been.calledOnce;
expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
buildUrl("/schema/1/staged/status", {
format: "semantic",
color: "ansi",
}),
{ ...commonFetchParams, method: "GET" },
);
expect(logger.stdout).to.have.been.calledWith(diff);
Expand All @@ -127,7 +136,10 @@ describe("schema commit", function () {

expect(fetch).to.have.been.calledOnce;
expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/status", { diff: "true", color: "ansi" }),
buildUrl("/schema/1/staged/status", {
format: "semantic",
color: "ansi",
}),
{ ...commonFetchParams, method: "GET" },
);
expect(logger.stdout).to.have.been.calledWith("Commit cancelled");
Expand Down
12 changes: 4 additions & 8 deletions test/commands/schema/diff.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ describe("schema diff", function () {
expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/diff", {
color: "ansi",
diff: "semantic",
force: "true",
format: "semantic",
staged: "true",
}),
{ ...commonFetchParams, method: "POST", body: reformatFSL(fsl) },
Expand All @@ -74,8 +73,7 @@ describe("schema diff", function () {
expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/diff", {
color: "ansi",
diff: "semantic",
force: "true",
format: "semantic",
staged: "false",
}),
{ ...commonFetchParams, method: "POST", body: reformatFSL(fsl) },
Expand All @@ -100,9 +98,8 @@ describe("schema diff", function () {
});
expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/diff", {
force: "true",
staged: "true",
diff: "semantic",
format: "semantic",
}),
{ ...commonFetchParams, method: "POST", body: reformatFSL(fsl) },
);
Expand All @@ -126,10 +123,9 @@ describe("schema diff", function () {
);
expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/diff", {
force: "true",
color: "ansi",
staged: "true",
diff: "semantic",
format: "semantic",
}),
{ ...commonFetchParams, method: "POST", body: reformatFSL(fsl) },
);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/schema/push.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("schema push", function () {
expect(gatherFSL).to.have.been.calledWith(".");

expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/update", { force: "true", staged: "true" }),
buildUrl("/schema/1/update", { staged: "true" }),
{
method: "POST",
headers: { AUTHORIZATION: "Bearer secret" },
Expand Down

0 comments on commit 8e1ec8b

Please sign in to comment.