Skip to content

Commit

Permalink
Fix shell commands tests by waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
ecooper committed Dec 9, 2024
1 parent 311b947 commit 4b34f39
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/shell.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe("shell", function () {

// start the shell
const runPromise = run(
`shell --secret "secret" --format json`,
`shell --secret "secret" --format json --no-color`,
container,
);
// Wait for the shell to start (print ">")
Expand Down Expand Up @@ -175,6 +175,7 @@ describe("shell", function () {
// confirm feedback that .clearhistory command was run
stdout.clear();
stdin.push(`${command}\n`);
await sleep(50);
await stdout.waitForWritten();
expect(stdout.getWritten()).to.equal(expected);

Check failure on line 180 in test/shell.mjs

View workflow job for this annotation

GitHub Actions / JUnit Test Report

/home/runner/work/fauna-shell/fauna-shell/test/shell.mjs.shell common history can be cleared

expected '.clearhistory\r\nHistory cleared\n\u0…' to equal '.clearhistory\r\nHistory cleared\n\u0…'
Raw output
AssertionError: expected '.clearhistory\r\nHistory cleared\n\u0…' to equal '.clearhistory\r\nHistory cleared\n\u0…'
    at Context.<anonymous> (file:///home/runner/work/fauna-shell/fauna-shell/test/shell.mjs:180:40)

      + expected - actual

       .clearhistory
       History cleared
      -[1G[0J> [3G
      -[1G[0J> [3G
      -[1G[0J> [3G
       [1G[0J> [3G

Expand Down Expand Up @@ -212,7 +213,7 @@ describe("shell", function () {

// start the shell
const runPromise = run(
`shell --secret "secret" --format json`,
`shell --secret "secret" --format json --no-color`,
container,
);
// Wait for the shell to start (print ">")
Expand Down Expand Up @@ -263,6 +264,7 @@ describe("shell", function () {

// send our first command
stdin.push(`${query}\n`);
await sleep(50);
await stdout.waitForWritten();

// validate
Expand All @@ -279,6 +281,7 @@ describe("shell", function () {
query = "Database.all().take(1)";
stdin.push(`${query}\n`);
stdin.push(null); // terminate the shell
await sleep(50);
await stdout.waitForWritten();

// validate second object
Expand Down

0 comments on commit 4b34f39

Please sign in to comment.