mirror of
https://github.com/caprover/caprover
synced 2025-10-30 10:07:01 +00:00
test: only run backup tests in CI
This commit is contained in:
@@ -29,64 +29,75 @@ afterEach(() => {
|
|||||||
return cleanup()
|
return cleanup()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('No backup file', () => {
|
if (process.env.CI) {
|
||||||
const bk = new BackupManager()
|
describe('backup tests [CI only]', backupTests)
|
||||||
return Promise.resolve()
|
} else {
|
||||||
.then(function () {
|
describe.skip('backup tests [CI only]', backupTests)
|
||||||
return bk.checkAndPrepareRestoration()
|
}
|
||||||
})
|
|
||||||
.then(function (data) {
|
|
||||||
expect(data).toBeFalsy()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test('Test backup file', () => {
|
function backupTests() {
|
||||||
const bk = new BackupManager()
|
test('No backup file', () => {
|
||||||
return Promise.resolve()
|
const bk = new BackupManager()
|
||||||
.then(function () {
|
return Promise.resolve()
|
||||||
return copy(`${__dirname}/backup.tar`, BACKUP_FILE_PATH_ABSOLUTE)
|
.then(function () {
|
||||||
})
|
return bk.checkAndPrepareRestoration()
|
||||||
.then(function () {
|
})
|
||||||
return bk.checkAndPrepareRestoration()
|
.then(function (data) {
|
||||||
})
|
expect(data).toBeFalsy()
|
||||||
.then(function () {
|
})
|
||||||
return readJson(
|
})
|
||||||
CaptainConstants.restoreDirectoryPath +
|
|
||||||
'/restore-instructions.json'
|
test('Test backup file', () => {
|
||||||
)
|
const bk = new BackupManager()
|
||||||
})
|
return Promise.resolve()
|
||||||
.then(function (ret: RestoringInfo) {
|
.then(function () {
|
||||||
const expectedValue = {
|
return copy(
|
||||||
nodesMapping: [
|
`${__dirname}/backup.tar`,
|
||||||
{
|
BACKUP_FILE_PATH_ABSOLUTE
|
||||||
newIp: 'CURRENT_NODE_DONT_CHANGE',
|
)
|
||||||
oldIp: '123.123.123.123',
|
})
|
||||||
privateKeyPath: '',
|
.then(function () {
|
||||||
user: '',
|
return bk.checkAndPrepareRestoration()
|
||||||
},
|
})
|
||||||
],
|
.then(function () {
|
||||||
oldNodesForReference: [
|
return readJson(
|
||||||
{
|
CaptainConstants.restoreDirectoryPath +
|
||||||
nodeData: {
|
'/restore-instructions.json'
|
||||||
nodeId: '123456789',
|
)
|
||||||
type: 'manager',
|
})
|
||||||
isLeader: true,
|
.then(function (ret: RestoringInfo) {
|
||||||
hostname: 'test',
|
const expectedValue = {
|
||||||
architecture: 'x86_64',
|
nodesMapping: [
|
||||||
operatingSystem: 'linux',
|
{
|
||||||
nanoCpu: 8000000000,
|
newIp: 'CURRENT_NODE_DONT_CHANGE',
|
||||||
memoryBytes: 8241434624,
|
oldIp: '123.123.123.123',
|
||||||
dockerEngineVersion: '18.09.2',
|
privateKeyPath: '',
|
||||||
ip: '123.123.123.123',
|
user: '',
|
||||||
state: 'ready',
|
|
||||||
status: 'active',
|
|
||||||
},
|
},
|
||||||
appsLockOnThisNode: ['pers1'],
|
],
|
||||||
},
|
oldNodesForReference: [
|
||||||
],
|
{
|
||||||
}
|
nodeData: {
|
||||||
expect(isDeepStrictEqual(ret, expectedValue)).toBe(true)
|
nodeId: '123456789',
|
||||||
ret.nodesMapping[0].oldIp += ' '
|
type: 'manager',
|
||||||
expect(isDeepStrictEqual(ret, expectedValue)).toBe(false)
|
isLeader: true,
|
||||||
})
|
hostname: 'test',
|
||||||
})
|
architecture: 'x86_64',
|
||||||
|
operatingSystem: 'linux',
|
||||||
|
nanoCpu: 8000000000,
|
||||||
|
memoryBytes: 8241434624,
|
||||||
|
dockerEngineVersion: '18.09.2',
|
||||||
|
ip: '123.123.123.123',
|
||||||
|
state: 'ready',
|
||||||
|
status: 'active',
|
||||||
|
},
|
||||||
|
appsLockOnThisNode: ['pers1'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
expect(isDeepStrictEqual(ret, expectedValue)).toBe(true)
|
||||||
|
ret.nodesMapping[0].oldIp += ' '
|
||||||
|
expect(isDeepStrictEqual(ret, expectedValue)).toBe(false)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user