test: migration from Python to JavaScript

This commit is contained in:
Francis Lachapelle
2021-11-10 01:54:35 -05:00
parent 54dae3bc28
commit 7474967c4f

View File

@@ -6,15 +6,18 @@ const path = require('path')
const { execSync } = require('child_process')
describe('sogo-tool tests', function() {
let tmpdir, userdir
let tmpdir, isRoot
beforeAll(function() {
const { homedir } = os.userInfo()
userdir = homedir
const { uid } = os.userInfo()
isRoot = (uid == 0)
})
beforeEach(function() {
tmpdir = mkdtempSync(path.join(userdir, 'sogo-'))
tmpdir = mkdtempSync(path.join(os.tmpdir(), 'sogo-'))
if (isRoot) {
execSync(`chown -R sogo:sogo ${tmpdir}`)
}
})
afterEach(function() {
@@ -22,8 +25,7 @@ describe('sogo-tool tests', function() {
})
it('backup', async function() {
const { uid } = os.userInfo()
const sudo = uid == 0 ? `sudo -u sogo ` : ``
const sudo = isRoot ? `sudo -u sogo ` : ``
execSync(`${sudo}sogo-tool backup ${tmpdir} ${config.username}`, (error, stdout, stderr) => {
expect(error).not.toBeDefined()
})