diff --git a/src/commands/local.mjs b/src/commands/local.mjs index 0a3bcc32..95b9cfab 100644 --- a/src/commands/local.mjs +++ b/src/commands/local.mjs @@ -34,19 +34,19 @@ function buildLocalCommand(yargs) { }, hostPort: { describe: - "The port on the host machine mapped to the container's port. This is the port you'll connect to Fauna on.", + "The port on the host machine mapped to the container's port. This is the port you'll connect to Fauna on.", type: "number", default: 8443, }, interval: { describe: - "The interval (in milliseconds) between health check attempts. Determines how often the CLI checks if the Fauna container is ready.", + "The interval (in milliseconds) between health check attempts. Determines how often the CLI checks if the Fauna container is ready.", type: "number", default: 10000, }, maxAttempts: { describe: - "The maximum number of health check attempts before declaring the start Fauna continer process as failed.", + "The maximum number of health check attempts before declaring the start Fauna continer process as failed.", type: "number", default: 100, }, @@ -63,10 +63,15 @@ function buildLocalCommand(yargs) { }) .check((argv) => { if (argv.maxAttempts < 1) { - throw new CommandError("--maxAttempts must be greater than 0.", { hideHelp: false }); + throw new CommandError("--maxAttempts must be greater than 0.", { + hideHelp: false, + }); } if (argv.interval < 0) { - throw new CommandError("--interval must be greater than or equal to 0.", { hideHelp: false }); + throw new CommandError( + "--interval must be greater than or equal to 0.", + { hideHelp: false }, + ); } return true; }); diff --git a/test/local.mjs b/test/local.mjs index 240c743d..26ccb319 100644 --- a/test/local.mjs +++ b/test/local.mjs @@ -71,6 +71,29 @@ describe.only("ensureContainerRunning", () => { ); }); + it("Skips pull if --pull is false.", async () => { + docker.listContainers.onCall(0).resolves([]); + fetch.onCall(0).resolves(f({})); // fast succeed the health check + logsStub.callsFake(async () => ({ + on: () => {}, + destroy: () => {}, + })); + docker.createContainer.resolves({ + start: startStub, + logs: logsStub, + unpause: unpauseStub, + }); + await run("local --pull false", container); + expect(docker.pull).not.to.have.been.called; + expect(docker.modem.followProgress).not.to.have.been.called; + expect(startStub).to.have.been.called; + expect(logsStub).to.have.been.called; + expect(docker.createContainer).to.have.been.called; + expect(logger.stderr).to.have.been.calledWith( + "[ContainerReady] Container 'faunadb' is up and healthy.", + ); + }); + it("Throws an error if the health check fails", async () => { process.env.FAUNA_LOCAL_HEALTH_CHECK_INTERVAL_MS = "1"; docker.pull.onCall(0).resolves();