Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ptpaterson authored and cleve-fauna committed Jan 29, 2025
1 parent 819d921 commit 7a49957
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
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
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 7a49957

Please sign in to comment.