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) {
console.log(ctx.request.body)
const db = new CouchDB(ctx.appId)
const plus = ctx.request.body.datasource.plus
const fetchSchema = ctx.request.body.fetchSchema

View File

@ -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)

View File

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