fix tests

This commit is contained in:
Peter Clement 2021-09-28 15:29:42 +01:00
parent eed3bdcb6b
commit 22bbbb5ba4
3 changed files with 15 additions and 8 deletions

View File

@ -75,6 +75,7 @@ exports.update = async function (ctx) {
} }
exports.save = async function (ctx) { exports.save = async function (ctx) {
console.log(ctx.request.body)
const db = new CouchDB(ctx.appId) const db = new CouchDB(ctx.appId)
const plus = ctx.request.body.datasource.plus const plus = ctx.request.body.datasource.plus
const fetchSchema = ctx.request.body.fetchSchema const fetchSchema = ctx.request.body.fetchSchema

View File

@ -1,6 +1,7 @@
// mock out postgres for this // mock out postgres for this
jest.mock("pg") jest.mock("pg")
const { findLastKey } = require("lodash/fp")
const setup = require("./utilities") const setup = require("./utilities")
const { checkBuilderEndpoint } = require("./utilities/TestFunctions") const { checkBuilderEndpoint } = require("./utilities/TestFunctions")
const { basicQuery, basicDatasource } = setup.structures const { basicQuery, basicDatasource } = setup.structures
@ -19,10 +20,10 @@ describe("/queries", () => {
}) })
async function createInvalidIntegration() { async function createInvalidIntegration() {
const datasource = await config.createDatasource({ const datasource = await config.createDatasource({datasource: {
...basicDatasource(), ...basicDatasource().datasource,
source: "INVALID_INTEGRATION", source: "INVALID_INTEGRATION",
}) }})
const query = await config.createQuery() const query = await config.createQuery()
return { datasource, query } return { datasource, query }
} }
@ -183,11 +184,14 @@ describe("/queries", () => {
}) })
it("should fail with invalid integration type", async () => { it("should fail with invalid integration type", async () => {
const { query } = await createInvalidIntegration() const { query, datasource } = await createInvalidIntegration()
await request await request
.post(`/api/queries/${query._id}`) .post(`/api/queries/${query._id}`)
.send({ .send({
datasourceId: datasource._id,
parameters: {}, parameters: {},
fields: {},
queryVerb: "read",
}) })
.set(config.defaultHeaders()) .set(config.defaultHeaders())
.expect(400) .expect(400)

View File

@ -70,10 +70,12 @@ exports.basicRole = () => {
exports.basicDatasource = () => { exports.basicDatasource = () => {
return { return {
datasource: {
type: "datasource", type: "datasource",
name: "Test", name: "Test",
source: "POSTGRES", source: "POSTGRES",
config: {}, config: {},
},
} }
} }