Fixing test cases, making it possible to still run automations via env variable.

This commit is contained in:
mike12345567 2021-09-14 11:18:02 +01:00
parent a5dbcd81bd
commit 500179e312
3 changed files with 15 additions and 9 deletions

View File

@ -23,6 +23,7 @@ process.env.MINIO_SECRET_KEY = "budibase"
process.env.COUCH_DB_USER = "budibase"
process.env.COUCH_DB_PASSWORD = "budibase"
process.env.INTERNAL_API_KEY = "budibase"
process.env.ALLOW_DEV_AUTOMATIONS = 1
// Stop info logs polluting test outputs
process.env.LOG_LEVEL = "error"

View File

@ -8,6 +8,7 @@ const { isDevAppID } = require("../db/utils")
const { queue } = require("./bullboard")
const { checkTestFlag } = require("../utilities/redis")
const utils = require("./utils")
const env = require("../environment")
const TRIGGER_DEFINITIONS = definitions
@ -30,21 +31,24 @@ async function queueRelevantRowAutomations(event, eventType) {
})
for (let automation of automations) {
// don't queue events which are for dev apps, only way to test automations is
// running tests on them
// in production the test flag will never be checked due to lazy evaluation (first always false)
if (isDevAppID(event.appId) && !(await checkTestFlag(automation._id))) {
return
}
let automationDef = automation.definition
let automationTrigger = automationDef ? automationDef.trigger : {}
// don't queue events which are for dev apps, only way to test automations is
// running tests on them, in production the test flag will never
// be checked due to lazy evaluation (first always false)
if (
!automationTrigger.inputs ||
automationTrigger.inputs.tableId !== event.row.tableId
!env.ALLOW_DEV_AUTOMATIONS &&
isDevAppID(event.appId) &&
!(await checkTestFlag(automation._id))
) {
continue
}
await queue.add({ automation, event })
if (
automationTrigger.inputs &&
automationTrigger.inputs.tableId === event.row.tableId
) {
await queue.add({ automation, event })
}
}
}

View File

@ -55,6 +55,7 @@ module.exports = {
BUDIBASE_API_KEY: process.env.BUDIBASE_API_KEY,
USERID_API_KEY: process.env.USERID_API_KEY,
DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL,
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
_set(key, value) {
process.env[key] = value
module.exports[key] = value