Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before(async () => {
UnityCacheServer.constructor._cache_instance = null;
const tmpPath = tmp.tmpNameSync();
process.env.NODE_CONFIG = JSON.stringify({
Server: {
port: 0
},
Cache: {
defaultModule: "cache_fs",
options: {
workers: 1, // test to ensure clustering is disabled automatically
cache_fs: {
cachePath: tmpPath
}
}
},
Diagnostics: {
clientRecorder: true,
tempOutputDir: function tempOutputDir (customDir) {
return customDir ? path.join(os.tmpdir(), customDir) : tmp.tmpNameSync({ prefix: 'electron-installer-redhat-' })
},
function installerOptions (asar, testOptions) {
const options = {}
const appName = asar ? 'footest' : 'bartest'
options.src = asar ? 'test/fixtures/app-with-asar/' : 'test/fixtures/app-without-asar/'
options.dest = tmp.tmpNameSync({ prefix: 'electron-installer-windows-' })
options.options = testOptions
options.rename = (dest, src) => {
const ext = path.extname(src)
if (ext === '.exe' || ext === '.msi') {
src = `<%= name %>-<%= version %>-installer${ext}`
}
return path.join(dest, src)
}
return [appName, options]
}
before(() => {
const tmpDir = tmp.tmpNameSync();
db = new loki('test.db');
rm = new ReliabilityManager(db, tmpDir, {reliabilityThreshold: 2, saveUnreliableVersionArtifacts: true});
});
before(() => {
UnityCacheServer.constructor._cache_instance = null;
this._tmpPath = tmp.tmpNameSync();
this._cacheOpts = {
test: true,
persistenceOptions: {
autosave: false
}
};
process.env.NODE_CONFIG = JSON.stringify({
Cache: {
defaultModule: "cache_fs",
options: { cache_fs: { cachePath: this._tmpPath } }
}
});
});
module.exports = function (desc, asar, options) {
let appName
asar ? appName = 'footest' : appName = 'bartest'
if (!options) options = {}
asar ? options.src = 'test/fixtures/app-with-asar/' : options.src = 'test/fixtures/app-without-asar/'
options.dest = tmp.tmpNameSync({ prefix: 'electron-installer-windows-' })
const args = ['--src', options.src, '--dest', options.dest]
if (options.certificateFile && options.certificatePassword) {
args.push('--certificateFile', options.certificateFile)
args.push('--certificatePassword', options.certificatePassword)
}
if (options.remoteReleases) args.push('--remoteReleases', options.remoteReleases)
describe(desc, test => {
before(async () => {
const logs = await spawn('./src/cli.js', args, null, null)
printLogs(logs)
})
after(async () => fs.remove(options.dest))
module.exports.tempOutputDir = function tempOutputDir (customDir) {
return customDir ? path.join(os.tmpdir(), customDir) : tmp.tmpNameSync({ prefix: 'electron-installer-debian-' })
}
options: {
cachePath: tmp.tmpNameSync({}),
pageSize: 1024 * 1024,
minFreeBlockSize: 1024,
persistenceOptions: {
autosave: false,
adapter: new loki.LokiMemoryAdapter()
},
highReliability: false
}
},
{
name: "cache_fs",
path: "../lib/cache/cache_fs",
options: {
cachePath: tmp.tmpNameSync({}),
highReliability: false,
persistenceOptions: {
autosave: false
}
}
}
];
describe("Cache API", function() {
this.slow(300);
test_modules.forEach(module => {
describe(module.name, () => {
let CacheModule, cache;
before(() => {