Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass false to dbExists when db does not exists #261

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/routes/renderRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ routes.database = async (req, res) => {
const { username, dbPassword } = user || {};
const renderData = { email, username, dbPassword, database };
renderData.dbHost = prod() ? dbHost[database] : dev_dbHost[database];
renderData.dbExists = username && (await checkAccount[database](username));
renderData.dbExists = username && (await checkAccount[database](username)) || false;
res.render("tutorial", renderData);
};

Expand Down
3 changes: 3 additions & 0 deletions src/routes/renderRoutes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ describe("Testing database router", () => {
expect(mockResponse.render.mock.calls[0][1].dbHost).toEqual(
process.env.ARANGO_URL
);
expect(mockResponse.render.mock.calls[0][1].dbExists).toEqual(false);
});
test("when database function is called with non-logged in user and Postgres parameter", async () => {
process.env = { ...process.env, NODE_ENV: "dev" };
Expand All @@ -74,6 +75,7 @@ describe("Testing database router", () => {
expect(mockResponse.render.mock.calls[0][1].dbHost).toEqual(
process.env.HOST
);
expect(mockResponse.render.mock.calls[0][1].dbExists).toEqual(false);
});
test("when database function is called with non-logged in user and Elasticsearch parameter", async () => {
process.env = { ...process.env, NODE_ENV: "dev" };
Expand All @@ -83,6 +85,7 @@ describe("Testing database router", () => {
expect(mockResponse.render.mock.calls[0][1].dbHost).toEqual(
process.env.ES_HOST
);
expect(mockResponse.render.mock.calls[0][1].dbExists).toEqual(false);
});
test("when database function is called with logged in user and Arango parameter", async () => {
process.env = { ...process.env, NODE_ENV: "dev" };
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/__snapshots__/welcome.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ exports[`test welcome page should render arango page correctly 1`] = `
const dbHost = \\"arangodb.learndatabases.dev\\";
const username = \\"\\";
const dbPassword = \\"\\";
const dbExists = ;
const dbExists = false;
const database = \\"Arango\\";

const credentials = document.createElement(\\"pre\\");
Expand Down Expand Up @@ -266,7 +266,7 @@ exports[`test welcome page should render elasticsearch page correctly 1`] = `
const dbHost = \\"elastic.learndatabases.dev\\";
const username = \\"\\";
const dbPassword = \\"\\";
const dbExists = ;
const dbExists = false;
const database = \\"Elasticsearch\\";

const credentials = document.createElement(\\"pre\\");
Expand Down Expand Up @@ -456,7 +456,7 @@ exports[`test welcome page should render postgres page correctly 1`] = `
const dbHost = \\"learndatabases.dev\\";
const username = \\"\\";
const dbPassword = \\"\\";
const dbExists = ;
const dbExists = false;
const database = \\"Postgres\\";

const credentials = document.createElement(\\"pre\\");
Expand Down