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",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"string",
|
"string",
|
||||||
|
"barcodeqr",
|
||||||
"longform",
|
"longform",
|
||||||
"options",
|
"options",
|
||||||
"number",
|
"number",
|
||||||
|
@ -986,6 +987,7 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"string",
|
"string",
|
||||||
|
"barcodeqr",
|
||||||
"longform",
|
"longform",
|
||||||
"options",
|
"options",
|
||||||
"number",
|
"number",
|
||||||
|
@ -1200,6 +1202,7 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"string",
|
"string",
|
||||||
|
"barcodeqr",
|
||||||
"longform",
|
"longform",
|
||||||
"options",
|
"options",
|
||||||
"number",
|
"number",
|
||||||
|
|
|
@ -579,6 +579,7 @@ components:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- string
|
- string
|
||||||
|
- barcodeqr
|
||||||
- longform
|
- longform
|
||||||
- options
|
- options
|
||||||
- number
|
- number
|
||||||
|
@ -741,6 +742,7 @@ components:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- string
|
- string
|
||||||
|
- barcodeqr
|
||||||
- longform
|
- longform
|
||||||
- options
|
- options
|
||||||
- number
|
- number
|
||||||
|
@ -910,6 +912,7 @@ components:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- string
|
- string
|
||||||
|
- barcodeqr
|
||||||
- longform
|
- longform
|
||||||
- options
|
- options
|
||||||
- number
|
- number
|
||||||
|
|
|
@ -20,7 +20,6 @@ import {
|
||||||
import { events } from "@budibase/backend-core"
|
import { events } from "@budibase/backend-core"
|
||||||
import { backups } from "@budibase/pro"
|
import { backups } from "@budibase/pro"
|
||||||
import { AppBackupTrigger } from "@budibase/types"
|
import { AppBackupTrigger } from "@budibase/types"
|
||||||
import env from "../../../environment"
|
|
||||||
|
|
||||||
// the max time we can wait for an invalidation to complete before considering it failed
|
// the max time we can wait for an invalidation to complete before considering it failed
|
||||||
const MAX_PENDING_TIME_MS = 30 * 60000
|
const MAX_PENDING_TIME_MS = 30 * 60000
|
||||||
|
@ -108,21 +107,17 @@ async function deployApp(deployment: any, userId: string) {
|
||||||
const devAppId = getDevelopmentAppID(appId)
|
const devAppId = getDevelopmentAppID(appId)
|
||||||
const productionAppId = getProdAppID(appId)
|
const productionAppId = getProdAppID(appId)
|
||||||
|
|
||||||
// can't do this in test
|
// don't try this if feature isn't allowed, will error
|
||||||
if (!env.isTest()) {
|
if (!(await backups.isEnabled())) {
|
||||||
// don't try this if feature isn't allowed, will error
|
// trigger backup initially
|
||||||
if (!(await backups.isEnabled())) {
|
await backups.triggerAppBackup(
|
||||||
// trigger backup initially
|
productionAppId,
|
||||||
await backups.triggerAppBackup(
|
AppBackupTrigger.PUBLISH,
|
||||||
productionAppId,
|
{
|
||||||
AppBackupTrigger.PUBLISH,
|
createdBy: userId,
|
||||||
{
|
}
|
||||||
createdBy: userId,
|
)
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const config: any = {
|
const config: any = {
|
||||||
source: devAppId,
|
source: devAppId,
|
||||||
target: productionAppId,
|
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 context = require("@budibase/backend-core/context")
|
||||||
const { generateDevInfoID, SEPARATOR } = require("@budibase/backend-core/db")
|
const { generateDevInfoID, SEPARATOR } = require("@budibase/backend-core/db")
|
||||||
const { encrypt } = require("@budibase/backend-core/encryption")
|
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 GLOBAL_USER_ID = "us_uuid1"
|
||||||
const EMAIL = "babs@babs.com"
|
const EMAIL = "babs@babs.com"
|
||||||
|
@ -95,7 +95,10 @@ class TestConfiguration {
|
||||||
|
|
||||||
// use a new id as the name to avoid name collisions
|
// use a new id as the name to avoid name collisions
|
||||||
async init(appName = newid()) {
|
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)
|
return this.createApp(appName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue