[Groonga-commit] groonga/gcs [master] Add helper functions to collect API responses

Zurück zum Archiv-Index

YUKI Hiroshi null+****@clear*****
Mon Nov 12 16:10:41 JST 2012


YUKI Hiroshi	2012-11-12 16:10:41 +0900 (Mon, 12 Nov 2012)

  New Revision: 525ade26996867808824a5f5015e6e2916273744
  https://github.com/groonga/gcs/commit/525ade26996867808824a5f5015e6e2916273744

  Log:
    Add helper functions to collect API responses

  Modified files:
    test/test-utils.js

  Modified: test/test-utils.js (+35 -2)
===================================================================
--- test/test-utils.js    2012-11-12 15:42:49 +0900 (337c9ef)
+++ test/test-utils.js    2012-11-12 16:10:41 +0900 (ac0b5b0)
@@ -192,10 +192,43 @@ function run() {
 exports.run = run;
 Deferred.register('run', function() { return run.apply(this, arguments); });
 
-
-exports.resolve = function(possibleRelativePath) {
+function resolve(possibleRelativePath) {
   return path.resolve(process.cwd(), possibleRelativePath);
+}
+exports.resolve = resolve;
+
+function toTimeStamp(date) {
+  return date.getFullYear() + 'y' +
+           ('0' + (date.getMonth() + 1)).slice(-2) + 'm' +
+           ('0' + (date.getDate())).slice(-2) + 'd' +
+           ('0' + (date.getHours())).slice(-2) + 'h' +
+           ('0' + (date.getMinutes())).slice(-2) + 'm' +
+           ('0' + (date.getSeconds())).slice(-2) + '.' +
+           date.getMilliseconds() + 's';
+}
+exports.toTimeStamp = toTimeStamp;
+
+function setupResponses(scenarios, date) {
+  if (!date) date = new Date();
+  var outputDir = path.join(temporaryDirectory, 'results.' + toTimeStamp(date));
+  if (path.existsSync(outputDir)) {
+    return Deferred.next(function() {
+      return outputDir;
+    });
+  }
+
+  var deferred = new Deferred();
+
+  return run(resolve('tools/run-scenarios'),
+               '--endpoint', '127.0.0.1.xip.io:' + testPort,
+               '--scenarios', scenarios,
+               '--output-directory', outputDir)
+           .next(function() {
+             return outputDir;
+           });
 };
+exports.setupResponses = setupResponses;
+
 
 // activate diff for chai.assert.deepEqual
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index