From 22bbbb5ba488bd72b88055561b02cdd614a705bd Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Tue, 28 Sep 2021 15:29:42 +0100 Subject: [PATCH] fix tests --- packages/server/src/api/controllers/datasource.js | 1 + packages/server/src/api/routes/tests/query.spec.js | 12 ++++++++---- packages/server/src/tests/utilities/structures.js | 10 ++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/server/src/api/controllers/datasource.js b/packages/server/src/api/controllers/datasource.js index 2ff7c7f9b8..7ebe8b9a5b 100644 --- a/packages/server/src/api/controllers/datasource.js +++ b/packages/server/src/api/controllers/datasource.js @@ -75,6 +75,7 @@ exports.update = async function (ctx) { } exports.save = async function (ctx) { + console.log(ctx.request.body) const db = new CouchDB(ctx.appId) const plus = ctx.request.body.datasource.plus const fetchSchema = ctx.request.body.fetchSchema diff --git a/packages/server/src/api/routes/tests/query.spec.js b/packages/server/src/api/routes/tests/query.spec.js index eadd475ed4..716817509b 100644 --- a/packages/server/src/api/routes/tests/query.spec.js +++ b/packages/server/src/api/routes/tests/query.spec.js @@ -1,6 +1,7 @@ // mock out postgres for this jest.mock("pg") +const { findLastKey } = require("lodash/fp") const setup = require("./utilities") const { checkBuilderEndpoint } = require("./utilities/TestFunctions") const { basicQuery, basicDatasource } = setup.structures @@ -19,10 +20,10 @@ describe("/queries", () => { }) async function createInvalidIntegration() { - const datasource = await config.createDatasource({ - ...basicDatasource(), + const datasource = await config.createDatasource({datasource: { + ...basicDatasource().datasource, source: "INVALID_INTEGRATION", - }) + }}) const query = await config.createQuery() return { datasource, query } } @@ -183,11 +184,14 @@ describe("/queries", () => { }) it("should fail with invalid integration type", async () => { - const { query } = await createInvalidIntegration() + const { query, datasource } = await createInvalidIntegration() await request .post(`/api/queries/${query._id}`) .send({ + datasourceId: datasource._id, parameters: {}, + fields: {}, + queryVerb: "read", }) .set(config.defaultHeaders()) .expect(400) diff --git a/packages/server/src/tests/utilities/structures.js b/packages/server/src/tests/utilities/structures.js index e4b2c7e1f0..9c900fec09 100644 --- a/packages/server/src/tests/utilities/structures.js +++ b/packages/server/src/tests/utilities/structures.js @@ -70,10 +70,12 @@ exports.basicRole = () => { exports.basicDatasource = () => { return { - type: "datasource", - name: "Test", - source: "POSTGRES", - config: {}, + datasource: { + type: "datasource", + name: "Test", + source: "POSTGRES", + config: {}, + }, } }