Merge branch 'feature/app-backups' of github.com:Budibase/budibase into feature/app-backups
This commit is contained in:
commit
4d0f5f22ac
|
@ -783,6 +783,7 @@
|
|||
"type": "string",
|
||||
"enum": [
|
||||
"string",
|
||||
"barcodeqr",
|
||||
"longform",
|
||||
"options",
|
||||
"number",
|
||||
|
@ -986,6 +987,7 @@
|
|||
"type": "string",
|
||||
"enum": [
|
||||
"string",
|
||||
"barcodeqr",
|
||||
"longform",
|
||||
"options",
|
||||
"number",
|
||||
|
@ -1200,6 +1202,7 @@
|
|||
"type": "string",
|
||||
"enum": [
|
||||
"string",
|
||||
"barcodeqr",
|
||||
"longform",
|
||||
"options",
|
||||
"number",
|
||||
|
|
|
@ -579,6 +579,7 @@ components:
|
|||
type: string
|
||||
enum:
|
||||
- string
|
||||
- barcodeqr
|
||||
- longform
|
||||
- options
|
||||
- number
|
||||
|
@ -741,6 +742,7 @@ components:
|
|||
type: string
|
||||
enum:
|
||||
- string
|
||||
- barcodeqr
|
||||
- longform
|
||||
- options
|
||||
- number
|
||||
|
@ -910,6 +912,7 @@ components:
|
|||
type: string
|
||||
enum:
|
||||
- string
|
||||
- barcodeqr
|
||||
- longform
|
||||
- options
|
||||
- number
|
||||
|
|
|
@ -20,7 +20,6 @@ import {
|
|||
import { events } from "@budibase/backend-core"
|
||||
import { backups } from "@budibase/pro"
|
||||
import { AppBackupTrigger } from "@budibase/types"
|
||||
import env from "../../../environment"
|
||||
|
||||
// the max time we can wait for an invalidation to complete before considering it failed
|
||||
const MAX_PENDING_TIME_MS = 30 * 60000
|
||||
|
@ -108,21 +107,17 @@ async function deployApp(deployment: any, userId: string) {
|
|||
const devAppId = getDevelopmentAppID(appId)
|
||||
const productionAppId = getProdAppID(appId)
|
||||
|
||||
// can't do this in test
|
||||
if (!env.isTest()) {
|
||||
// don't try this if feature isn't allowed, will error
|
||||
if (!(await backups.isEnabled())) {
|
||||
// trigger backup initially
|
||||
await backups.triggerAppBackup(
|
||||
productionAppId,
|
||||
AppBackupTrigger.PUBLISH,
|
||||
{
|
||||
createdBy: userId,
|
||||
}
|
||||
)
|
||||
}
|
||||
// don't try this if feature isn't allowed, will error
|
||||
if (!(await backups.isEnabled())) {
|
||||
// trigger backup initially
|
||||
await backups.triggerAppBackup(
|
||||
productionAppId,
|
||||
AppBackupTrigger.PUBLISH,
|
||||
{
|
||||
createdBy: userId,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const config: any = {
|
||||
source: devAppId,
|
||||
target: productionAppId,
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
const setup = require("./utilities")
|
||||
const { events } = require("@budibase/backend-core")
|
||||
|
||||
describe("/deployments", () => {
|
||||
let request = setup.getRequest()
|
||||
let config = setup.getConfig()
|
||||
|
||||
afterAll(setup.afterAll)
|
||||
|
||||
beforeEach(async () => {
|
||||
await config.init()
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
describe("deploy", () => {
|
||||
it("should deploy the application", async () => {
|
||||
await request
|
||||
.post(`/api/deploy`)
|
||||
.set(config.defaultHeaders())
|
||||
.expect("Content-Type", /json/)
|
||||
.expect(200)
|
||||
expect(events.app.published.mock.calls.length).toBe(1)
|
||||
})
|
||||
})
|
||||
})
|
|
@ -0,0 +1,40 @@
|
|||
const triggerAppBackupMock = jest.fn()
|
||||
jest.mock("@budibase/pro", () => ({
|
||||
...jest.requireActual("@budibase/pro"),
|
||||
backups: {
|
||||
triggerAppBackup: triggerAppBackupMock,
|
||||
addAppBackupProcessors: jest.fn(),
|
||||
},
|
||||
}))
|
||||
import setup from "./utilities"
|
||||
import { events } from "@budibase/backend-core"
|
||||
import { AppBackupTrigger } from "@budibase/types"
|
||||
|
||||
describe("/deployments", () => {
|
||||
let request = setup.getRequest()
|
||||
let config = setup.getConfig()
|
||||
|
||||
afterAll(setup.afterAll)
|
||||
|
||||
beforeEach(async () => {
|
||||
await config.init()
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
describe("deploy", () => {
|
||||
it("should deploy the application", async () => {
|
||||
await request
|
||||
.post(`/api/deploy`)
|
||||
.set(config.defaultHeaders())
|
||||
.expect("Content-Type", /json/)
|
||||
.expect(200)
|
||||
expect(triggerAppBackupMock).toBeCalledTimes(1)
|
||||
expect(triggerAppBackupMock).toBeCalledWith(
|
||||
config.prodAppId,
|
||||
AppBackupTrigger.PUBLISH,
|
||||
{ createdBy: config.userMetadataId }
|
||||
)
|
||||
expect((events.app.published as jest.Mock).mock.calls.length).toBe(1)
|
||||
})
|
||||
})
|
||||
})
|
|
@ -25,7 +25,7 @@ const newid = require("../../db/newid")
|
|||
const context = require("@budibase/backend-core/context")
|
||||
const { generateDevInfoID, SEPARATOR } = require("@budibase/backend-core/db")
|
||||
const { encrypt } = require("@budibase/backend-core/encryption")
|
||||
const { DocumentType } = require("../../db/utils")
|
||||
const { DocumentType, generateUserMetadataID } = require("../../db/utils")
|
||||
|
||||
const GLOBAL_USER_ID = "us_uuid1"
|
||||
const EMAIL = "babs@babs.com"
|
||||
|
@ -95,7 +95,10 @@ class TestConfiguration {
|
|||
|
||||
// use a new id as the name to avoid name collisions
|
||||
async init(appName = newid()) {
|
||||
await this.globalUser()
|
||||
this.user = await this.globalUser()
|
||||
this.globalUserId = this.user._id
|
||||
this.userMetadataId = generateUserMetadataID(this.globalUserId)
|
||||
|
||||
return this.createApp(appName)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue