Skip to content

Commit d5c6174

Browse files
committed
test: only run backup tests in CI
1 parent 3a8f2a6 commit d5c6174

File tree

1 file changed

+70
-59
lines changed

1 file changed

+70
-59
lines changed

tests/backup.test.ts

Lines changed: 70 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -29,64 +29,75 @@ afterEach(() => {
2929
return cleanup()
3030
})
3131

32-
test('No backup file', () => {
33-
const bk = new BackupManager()
34-
return Promise.resolve()
35-
.then(function () {
36-
return bk.checkAndPrepareRestoration()
37-
})
38-
.then(function (data) {
39-
expect(data).toBeFalsy()
40-
})
41-
})
32+
if (process.env.CI) {
33+
describe('backup tests [CI only]', backupTests)
34+
} else {
35+
describe.skip('backup tests [CI only]', backupTests)
36+
}
4237

43-
test('Test backup file', () => {
44-
const bk = new BackupManager()
45-
return Promise.resolve()
46-
.then(function () {
47-
return copy(`${__dirname}/backup.tar`, BACKUP_FILE_PATH_ABSOLUTE)
48-
})
49-
.then(function () {
50-
return bk.checkAndPrepareRestoration()
51-
})
52-
.then(function () {
53-
return readJson(
54-
CaptainConstants.restoreDirectoryPath +
55-
'/restore-instructions.json'
56-
)
57-
})
58-
.then(function (ret: RestoringInfo) {
59-
const expectedValue = {
60-
nodesMapping: [
61-
{
62-
newIp: 'CURRENT_NODE_DONT_CHANGE',
63-
oldIp: '123.123.123.123',
64-
privateKeyPath: '',
65-
user: '',
66-
},
67-
],
68-
oldNodesForReference: [
69-
{
70-
nodeData: {
71-
nodeId: '123456789',
72-
type: 'manager',
73-
isLeader: true,
74-
hostname: 'test',
75-
architecture: 'x86_64',
76-
operatingSystem: 'linux',
77-
nanoCpu: 8000000000,
78-
memoryBytes: 8241434624,
79-
dockerEngineVersion: '18.09.2',
80-
ip: '123.123.123.123',
81-
state: 'ready',
82-
status: 'active',
38+
function backupTests() {
39+
test('No backup file', () => {
40+
const bk = new BackupManager()
41+
return Promise.resolve()
42+
.then(function () {
43+
return bk.checkAndPrepareRestoration()
44+
})
45+
.then(function (data) {
46+
expect(data).toBeFalsy()
47+
})
48+
})
49+
50+
test('Test backup file', () => {
51+
const bk = new BackupManager()
52+
return Promise.resolve()
53+
.then(function () {
54+
return copy(
55+
`${__dirname}/backup.tar`,
56+
BACKUP_FILE_PATH_ABSOLUTE
57+
)
58+
})
59+
.then(function () {
60+
return bk.checkAndPrepareRestoration()
61+
})
62+
.then(function () {
63+
return readJson(
64+
CaptainConstants.restoreDirectoryPath +
65+
'/restore-instructions.json'
66+
)
67+
})
68+
.then(function (ret: RestoringInfo) {
69+
const expectedValue = {
70+
nodesMapping: [
71+
{
72+
newIp: 'CURRENT_NODE_DONT_CHANGE',
73+
oldIp: '123.123.123.123',
74+
privateKeyPath: '',
75+
user: '',
8376
},
84-
appsLockOnThisNode: ['pers1'],
85-
},
86-
],
87-
}
88-
expect(isDeepStrictEqual(ret, expectedValue)).toBe(true)
89-
ret.nodesMapping[0].oldIp += ' '
90-
expect(isDeepStrictEqual(ret, expectedValue)).toBe(false)
91-
})
92-
})
77+
],
78+
oldNodesForReference: [
79+
{
80+
nodeData: {
81+
nodeId: '123456789',
82+
type: 'manager',
83+
isLeader: true,
84+
hostname: 'test',
85+
architecture: 'x86_64',
86+
operatingSystem: 'linux',
87+
nanoCpu: 8000000000,
88+
memoryBytes: 8241434624,
89+
dockerEngineVersion: '18.09.2',
90+
ip: '123.123.123.123',
91+
state: 'ready',
92+
status: 'active',
93+
},
94+
appsLockOnThisNode: ['pers1'],
95+
},
96+
],
97+
}
98+
expect(isDeepStrictEqual(ret, expectedValue)).toBe(true)
99+
ret.nodesMapping[0].oldIp += ' '
100+
expect(isDeepStrictEqual(ret, expectedValue)).toBe(false)
101+
})
102+
})
103+
}

0 commit comments

Comments
 (0)