Updating some test cases which were failing silently and changing how environment want handled.

This commit is contained in:
mike12345567 2020-09-14 14:32:20 +01:00
parent 82e73ae0ea
commit c4683a3743
5 changed files with 12 additions and 9 deletions

View File

@ -37,7 +37,7 @@ describe("/accesslevels", () => {
beforeEach(async () => {
instanceId = (await createInstance(request, appId))._id
model = await createModel(request, appId, instanceId)
view = await createView(request, appId, instanceId)
view = await createView(request, appId, instanceId, model._id)
})
describe("create", () => {
@ -111,7 +111,7 @@ describe("/accesslevels", () => {
await request
.get(`/api/accesslevels/${customLevel._id}`)
.set(defaultHeaders(appId, instanceId))
.expect(404)
.expect(404)
})
})

View File

@ -67,9 +67,10 @@ exports.createModel = async (request, appId, instanceId, model) => {
return res.body
}
exports.createView = async (request, appId, instanceId, view) => {
exports.createView = async (request, appId, instanceId, modelId, view) => {
view = view || {
map: "function(doc) { emit(doc[doc.key], doc._id); } ",
modelId: modelId,
}
const res = await request
@ -262,11 +263,7 @@ exports.builderEndpointShouldBlockNormalUsers = async ({
appId,
instanceId,
}) => {
const headers = await createUserWithAdminPermissions(
request,
appId,
instanceId
)
const headers = await createUserWithAdminPermissions(request, appId, instanceId)
await createRequest(request, method, url, body)
.set(headers)

View File

@ -120,6 +120,10 @@ describe("/models", () => {
testModel = await createModel(request, app._id, instance._id, testModel)
});
afterEach(() => {
delete testModel._rev
});
it("returns all the models for that instance in the response body", done => {
request
.get(`/api/models`)

View File

@ -7,4 +7,5 @@ module.exports = {
COUCH_DB_URL: process.env.COUCH_DB_URL,
SALT_ROUNDS: process.env.SALT_ROUNDS,
LOGGER: process.env.LOGGER,
BUDIBASE_ENVIRONMENT: process.env.BUDIBASE_ENVIRONMENT,
}

View File

@ -1,4 +1,5 @@
const triggers = require("./triggers")
const environment = require("../environment")
const workerFarm = require("worker-farm")
const singleThread = require("./thread")
@ -21,7 +22,7 @@ function runWorker(job) {
*/
module.exports.init = function() {
triggers.workflowQueue.process(async job => {
if (process.env.BUDIBASE_ENVIRONMENT === "PRODUCTION") {
if (environment.BUDIBASE_ENVIRONMENT === "PRODUCTION") {
await runWorker(job)
} else {
await singleThread(job)