Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
henryfauna committed Dec 11, 2024
1 parent 3eded61 commit 6b1b849
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
23 changes: 15 additions & 8 deletions src/commands/schema/status.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ async function doStatus(argv) {
});
}

// Output the status response
logger.stdout(`Staged changes: ${chalk.bold(statusResponse.status)}`);
if (statusResponse.pending_summary !== "") {
logger.stdout(statusResponse.pending_summary);
Expand All @@ -58,21 +59,27 @@ async function doStatus(argv) {
logger.stdout(statusResponse.diff.split("\n").join("\n "));
}

// Output the diff response
if (!hasLocalSchema) {
logger.stdout(
`Local changes: ${chalk.bold(`no schema files found in '${absoluteDirPath}'`)}\n`,
);
} else if (diffResponse.error) {
logger.stdout(`Local changes:`);
return;
}

if (diffResponse.error) {
throw new CommandError(diffResponse.error.message);
} else if (diffResponse.diff === "") {
}

if (diffResponse.diff === "") {
logger.stdout(`Local changes: ${chalk.bold("none")}\n`);
} else {
logger.stdout(`Local changes:\n`);
logger.stdout(` ${diffResponse.diff.split("\n").join("\n ")}`);
logger.stdout("(use `fauna schema diff` to display local changes)");
logger.stdout("(use `fauna schema push` to stage local changes)");
return;
}

logger.stdout(`Local changes:\n`);
logger.stdout(` ${diffResponse.diff.split("\n").join("\n ")}`);
logger.stdout("(use `fauna schema diff` to display local changes)");
logger.stdout("(use `fauna schema push` to stage local changes)");
}

function buildStatusCommand(yargs) {
Expand Down
22 changes: 11 additions & 11 deletions test/schema/status.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ describe("schema status", function () {
await run(`schema status --secret "secret"`, container);

expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/status", { diff: "summary", color: "ansi" }),
buildUrl("/schema/1/staged/status", { format: "summary", color: "ansi" }),
commonFetchParams,
);
expect(fetch).not.to.have.been.calledWith(
buildUrl("/schema/1/validate", {
diff: "summary",
format: "summary",
staged: "true",
version: "0",
color: "ansi",
Expand Down Expand Up @@ -140,12 +140,12 @@ describe("schema status", function () {
await run(`schema status --secret "secret"`, container);

expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/status", { diff: "summary", color: "ansi" }),
buildUrl("/schema/1/staged/status", { format: "summary", color: "ansi" }),
commonFetchParams,
);
expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/diff", {
diff: "summary",
format: "summary",
staged: "true",
version: "0",
color: "ansi",
Expand Down Expand Up @@ -184,12 +184,12 @@ describe("schema status", function () {
await run(`schema status --secret "secret"`, container);

expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/status", { diff: "summary", color: "ansi" }),
buildUrl("/schema/1/staged/status", { format: "summary", color: "ansi" }),
commonFetchParams,
);
expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/diff", {
diff: "summary",
format: "summary",
staged: "true",
version: "0",
color: "ansi",
Expand Down Expand Up @@ -233,13 +233,13 @@ describe("schema status", function () {
await run(`schema status --secret "secret"`, container);

expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/status", { diff: "summary", color: "ansi" }),
buildUrl("/schema/1/staged/status", { format: "summary", color: "ansi" }),
commonFetchParams,
);

expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/diff", {
diff: "summary",
format: "summary",
staged: "true",
version: "0",
color: "ansi",
Expand Down Expand Up @@ -281,12 +281,12 @@ describe("schema status", function () {
await run(`schema status --secret "secret"`, container);

expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/status", { diff: "summary", color: "ansi" }),
buildUrl("/schema/1/staged/status", { format: "summary", color: "ansi" }),
commonFetchParams,
);
expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/diff", {
diff: "summary",
format: "summary",
staged: "true",
version: "0",
color: "ansi",
Expand Down Expand Up @@ -325,7 +325,7 @@ describe("schema status", function () {
await run(`schema status --no-color --secret "secret"`, container);

expect(fetch).to.have.been.calledWith(
buildUrl("/schema/1/staged/status", { diff: "summary" }),
buildUrl("/schema/1/staged/status", { format: "summary" }),
commonFetchParams,
);
expect(logger.stderr).not.to.have.been.called;
Expand Down

0 comments on commit 6b1b849

Please sign in to comment.