uninstallApp () { logger.info('Uninstalling the app.'); const paramedicAppUninstall = new ParamedicAppUninstall(this.tempFolder.name, this.config.getPlatformId()); return paramedicAppUninstall.uninstallApp(this.targetObj, utilities.PARAMEDIC_DEFAULT_APP_NAME); }
maybeRunFileTransferServer () { return Q().then(() => { const plugins = this.config.getPlugins(); for (let i = 0; i < plugins.length; i++) { if (plugins[i].indexOf('cordova-plugin-file-transfer') >= 0 && !this.config.getFileTransferServer() && !this.config.isCI()) { return this.server.startFileTransferServer(this.tempFolder.name); } } }); }
test('Take screenshot', async t => { var screenshotName = getTempFileName({ template: 'screenshot-XXXXXX.png' }); var screenshotPath = path.join('.screenshots', screenshotName); await t.takeScreenshot(screenshotName); await t.expect(statSync(screenshotPath).isFile()).ok(); });
const stringToFile = string => new Promise((resolve, reject) => tmp.file({ postfix: '.html' }, (err, path) => { if (err) return reject(err.message) fs.writeFile(path, string, err => { if (err) return reject(err.message) return resolve(path) }) }) )
const tempout = function() { var file = tmp.fileSync({ mode: 0644, postfix: '.out' }); return file; }
test('.read() fails when index unspecified', t => { tmp.tmpName((err, path) => { if (err) t.fail('' + err); WriteAheadLog.create({ path }) .then(wal => wal.read() .then(() => t.fail('Should fail due to missing LSN.'))) .catch(err => { t.equal('' + err, 'AssertionError: index (number) is required'); t.end(); }); }); });
createTempProject () { this.tempFolder = tmp.dirSync(); tmp.setGracefulCleanup(); logger.info('cordova-paramedic: creating temp project at ' + this.tempFolder.name); exec(this.config.getCli() + ' create ' + this.tempFolder.name + utilities.PARAMEDIC_COMMON_CLI_ARGS); return this.tempFolder; }
collectDeviceLogs () { logger.info('Collecting logs for the devices.'); const outputDir = this.config.getOutputDir() ? this.config.getOutputDir() : this.tempFolder.name; const logMins = this.config.getLogMins() ? this.config.getLogMins() : utilities.DEFAULT_LOG_TIME; const paramedicLogCollector = new ParamedicLogCollector(this.config.getPlatformId(), this.tempFolder.name, outputDir, this.targetObj); paramedicLogCollector.collectLogs(logMins); }
test('WriteAheadLog.open({ path: \'random-temp\' }) fails when file doesn\'t exist', t => { tmp.tmpName((err, path) => { if (err) t.fail('' + err); WriteAheadLog.open({ path }) .then(wal => { t.fail(`Non-existent log should cause an error: ${wal.name}`); }) .catch(err => { t.equal(err.code, 'ENOENT', '' + err); t.end(); }); }); });
test('.truncate(lsn) fails when LSN out of range (ahead of entries)', t => { tmp.tmpName((err, path) => { if (err) t.fail('' + err); WriteAheadLog.create({ path }) .then(wal => wal.truncate(1)) .catch(err => { t.equal('' + err, 'AssertionError: index out of range', 'AssertionError: index out of range'); t.end(); }); }); });
test('.readRange() fails when arguments not specified', t => { tmp.tmpName((err, path) => { if (err) t.fail('' + err); WriteAheadLog.create({ path }) .then(wal => wal.readRange()) .catch(err => { t.equal('' + err, 'AssertionError: first (number) is required', 'AssertionError: first (number) is required'); t.end(); }); }); });