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 () => { beforeEach(async () => {
instanceId = (await createInstance(request, appId))._id instanceId = (await createInstance(request, appId))._id
model = await createModel(request, appId, instanceId) model = await createModel(request, appId, instanceId)
view = await createView(request, appId, instanceId) view = await createView(request, appId, instanceId, model._id)
}) })
describe("create", () => { describe("create", () => {

View File

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

View File

@ -120,6 +120,10 @@ describe("/models", () => {
testModel = await createModel(request, app._id, instance._id, testModel) 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 => { it("returns all the models for that instance in the response body", done => {
request request
.get(`/api/models`) .get(`/api/models`)

View File

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

View File

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