YUKI Hiroshi
null+****@clear*****
Wed Nov 14 17:55:27 JST 2012
YUKI Hiroshi 2012-11-14 17:55:27 +0900 (Wed, 14 Nov 2012) New Revision: 534f0a545e1c220fd35054a76c5a7270962f3f4f https://github.com/groonga/gcs/commit/534f0a545e1c220fd35054a76c5a7270962f3f4f Log: Raise error if the database is not blank Modified files: lib/client.js tools/run-scenarios tools/scenario-runner.js Modified: lib/client.js (+8 -0) =================================================================== --- lib/client.js 2012-11-14 17:37:10 +0900 (ae084f5) +++ lib/client.js 2012-11-14 17:55:27 +0900 (7db1123) @@ -321,6 +321,14 @@ Client.prototype = { self.raiseFatalError(domainName + ' does not exist. You must specify an existing domain name.'); callback(); }); + }, + + assertNoDomain: function(callback) { + this.getDomainStatuses(function(error, domains) { + if (!error && domains.length) + error = new Error(domains.length + ' domains exist unexpectedly.'); + callback(error); + }); } }; exports.Client = Client; Modified: tools/run-scenarios (+4 -0) =================================================================== --- tools/run-scenarios 2012-11-14 17:37:10 +0900 (3c96a36) +++ tools/run-scenarios 2012-11-14 17:55:27 +0900 (0a3bca6) @@ -102,6 +102,10 @@ runner.on('scenario', function(event) { console.log('Scenario file: ' + event.scenario.path); mkdirp.sync(event.scenario.resultsDir); + event.runner.on('error:fatal', function(event) { + commandLine.raiseFatalError(event.error); + }); + event.runner.on('end', function(event) { console.log(' Done. (elapsed time: ' + event.elapsedTime + 'msec)'); }); Modified: tools/scenario-runner.js (+13 -1) =================================================================== --- tools/scenario-runner.js 2012-11-14 17:37:10 +0900 (6f7d8a4) +++ tools/scenario-runner.js 2012-11-14 17:55:27 +0900 (c8b7f55) @@ -52,7 +52,19 @@ function ScenarioRunner(options) { ScenarioRunner.prototype = new EventEmitter(); ScenarioRunner.prototype.run = function(scenario) { - this._process(scenario); + var self = this; + this.client.assertNoDomain(function(error) { + if (error) + self.emit('error:fatal', { error: error }); + else + self._process(scenario); + }); +}; + +ScenarioRunner.prototype.assertNoDomain = function(callback) { + this.client.assertNoDomain(function(error) { + callback(); + }); }; ScenarioRunner.prototype._process = function(scenario, callback) { -------------- next part -------------- HTML����������������������������... Télécharger