diff --git a/src/lib/docker-containers.mjs b/src/lib/docker-containers.mjs index 282bd1ca..51416086 100644 --- a/src/lib/docker-containers.mjs +++ b/src/lib/docker-containers.mjs @@ -91,7 +91,10 @@ async function pullImage(imageName) { ); }); } catch (error) { - throw new CommandError(`[PullImage] Failed to pull image '${imageName}': ${error.message}. ${SUPPORT_MESSAGE}`, { cause: error }); + throw new CommandError( + `[PullImage] Failed to pull image '${imageName}': ${error.message}. ${SUPPORT_MESSAGE}`, + { cause: error }, + ); } } diff --git a/src/lib/errors.mjs b/src/lib/errors.mjs index 5f566a88..61bab418 100644 --- a/src/lib/errors.mjs +++ b/src/lib/errors.mjs @@ -4,8 +4,10 @@ import util from "util"; import { container } from "../cli.mjs"; -const BUG_REPORT_MESSAGE = "If you believe this is a bug, please report this issue on GitHub: https://github.com/fauna/fauna-shell/issues"; -export const SUPPORT_MESSAGE = "If this issue persists contact support: https://support.fauna.com/hc/en-us/requests/new"; +const BUG_REPORT_MESSAGE = + "If you believe this is a bug, please report this issue on GitHub: https://github.com/fauna/fauna-shell/issues"; +export const SUPPORT_MESSAGE = + "If this issue persists contact support: https://support.fauna.com/hc/en-us/requests/new"; /* * These are the error message prefixes that yargs throws during diff --git a/test/local.mjs b/test/local.mjs index d68cc50c..53c61558 100644 --- a/test/local.mjs +++ b/test/local.mjs @@ -71,6 +71,38 @@ describe("ensureContainerRunning", () => { ); }); + it("The user can control the hostPort and containerPort", async () => { + docker.pull.onCall(0).resolves(); + docker.modem.followProgress.callsFake((stream, onFinished) => { + onFinished(); + }); + 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 --hostPort 10 --containerPort 11", container); + expect(docker.createContainer).to.have.been.calledWith({ + Image: "fauna/faunadb:latest", + name: "faunadb", + HostConfig: { + PortBindings: { + "11/tcp": [{ HostPort: "10" }], + }, + AutoRemove: true, + }, + ExposedPorts: { + "11/tcp": {}, + }, + }); + }); + it("Skips pull if --pull is false.", async () => { docker.listContainers.onCall(0).resolves([]); fetch.onCall(0).resolves(f({})); // fast succeed the health check