Ensure a backup is complete before attempting to import it.
This commit is contained in:
parent
7c2fee4311
commit
c7ec698d30
|
@ -8,7 +8,6 @@ import { mocks } from "@budibase/backend-core/tests"
|
|||
mocks.licenses.useBackups()
|
||||
|
||||
describe("/backups", () => {
|
||||
let request = setup.getRequest()
|
||||
let config = setup.getConfig()
|
||||
|
||||
afterAll(setup.afterAll)
|
||||
|
@ -59,10 +58,8 @@ describe("/backups", () => {
|
|||
await config.createScreen()
|
||||
const exportRes = await config.api.backup.createBackup(appId)
|
||||
expect(exportRes.backupId).toBeDefined()
|
||||
const importRes = await config.api.backup.importBackup(
|
||||
appId,
|
||||
exportRes.backupId
|
||||
)
|
||||
await config.api.backup.waitForBackupToComplete(appId, exportRes.backupId)
|
||||
await config.api.backup.importBackup(appId, exportRes.backupId)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -31,6 +31,19 @@ export class BackupAPI extends TestAPI {
|
|||
return result.body as CreateAppBackupResponse
|
||||
}
|
||||
|
||||
waitForBackupToComplete = async (appId: string, backupId: string) => {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||
const result = await this.request
|
||||
.get(`/api/apps/${appId}/backups/${backupId}/file`)
|
||||
.set(this.config.defaultHeaders())
|
||||
if (result.status === 200) {
|
||||
return
|
||||
}
|
||||
}
|
||||
throw new Error("Backup did not complete")
|
||||
}
|
||||
|
||||
importBackup = async (
|
||||
appId: string,
|
||||
backupId: string
|
||||
|
|
Loading…
Reference in New Issue