[Groonga-commit] groonga/gcs-console [test] Add simple test and test utils

Back to archive index

Yoji SHIDARA null+****@clear*****
Tue Oct 23 18:24:36 JST 2012


Yoji SHIDARA	2012-10-23 18:24:36 +0900 (Tue, 23 Oct 2012)

  New Revision: 8cda143a7e0669f003f54a365748289b5942d66a
  https://github.com/groonga/gcs-console/commit/8cda143a7e0669f003f54a365748289b5942d66a

  Log:
    Add simple test and test utils

  Added files:
    test/index.test.js
  Modified files:
    npm-shrinkwrap.json
    package.json

  Modified: npm-shrinkwrap.json (+180 -7)
===================================================================
--- npm-shrinkwrap.json    2012-10-22 15:11:31 +0900 (7a0abce)
+++ npm-shrinkwrap.json    2012-10-23 18:24:36 +0900 (e357f91)
@@ -69,9 +69,6 @@
       "dependencies": {
         "commander": {
           "version": "0.6.1"
-        },
-        "mkdirp": {
-          "version": "0.3.4"
         }
       }
     },
@@ -81,9 +78,6 @@
         "fmt": {
           "version": "0.4.0"
         },
-        "underscore": {
-          "version": "1.4.2"
-        },
         "xml2js": {
           "version": "0.1.14",
           "dependencies": {
@@ -111,7 +105,7 @@
                   "version": "0.1.8"
                 },
                 "diff": {
-                  "version": "1.0.3"
+                  "version": "1.0.4"
                 }
               }
             }
@@ -124,6 +118,185 @@
     },
     "connect-flash": {
       "version": "0.1.0"
+    },
+    "mkdirp": {
+      "version": "0.3.4"
+    },
+    "rimraf": {
+      "version": "2.0.2",
+      "dependencies": {
+        "graceful-fs": {
+          "version": "1.1.14"
+        }
+      }
+    },
+    "chai": {
+      "version": "1.3.0"
+    },
+    "mocha": {
+      "version": "1.6.0",
+      "dependencies": {
+        "commander": {
+          "version": "0.6.1"
+        },
+        "growl": {
+          "version": "1.5.1"
+        },
+        "jade": {
+          "version": "0.26.3",
+          "dependencies": {
+            "mkdirp": {
+              "version": "0.3.0"
+            }
+          }
+        },
+        "diff": {
+          "version": "1.0.2"
+        },
+        "debug": {
+          "version": "0.7.0"
+        },
+        "mkdirp": {
+          "version": "0.3.3"
+        },
+        "ms": {
+          "version": "0.3.0"
+        }
+      }
+    },
+    "zombie": {
+      "version": "2.0.0-alpha7",
+      "dependencies": {
+        "contextify": {
+          "version": "0.1.3",
+          "dependencies": {
+            "bindings": {
+              "version": "1.0.0"
+            }
+          }
+        },
+        "eventsource": {
+          "version": "0.0.5"
+        },
+        "html5": {
+          "version": "0.3.8",
+          "dependencies": {
+            "opts": {
+              "version": "1.2.2"
+            },
+            "tap": {
+              "version": "0.1.4",
+              "dependencies": {
+                "inherits": {
+                  "version": "1.0.0"
+                },
+                "yamlish": {
+                  "version": "0.0.2"
+                },
+                "slide": {
+                  "version": "1.1.3"
+                },
+                "runforcover": {
+                  "version": "0.0.2",
+                  "dependencies": {
+                    "bunker": {
+                      "version": "0.1.2",
+                      "dependencies": {
+                        "burrito": {
+                          "version": "0.2.12",
+                          "dependencies": {
+                            "traverse": {
+                              "version": "0.5.2"
+                            },
+                            "uglify-js": {
+                              "version": "1.1.1"
+                            }
+                          }
+                        }
+                      }
+                    }
+                  }
+                }
+              }
+            },
+            "bench": {
+              "version": "0.3.4"
+            },
+            "async": {
+              "version": "0.1.22"
+            }
+          }
+        },
+        "jsdom": {
+          "version": "0.2.18",
+          "dependencies": {
+            "htmlparser": {
+              "version": "1.7.6"
+            },
+            "cssom": {
+              "version": "0.2.5"
+            },
+            "cssstyle": {
+              "version": "0.2.3"
+            }
+          }
+        },
+        "mime": {
+          "version": "1.2.7"
+        },
+        "ms": {
+          "version": "0.3.0"
+        },
+        "q": {
+          "version": "0.8.9"
+        },
+        "request": {
+          "version": "2.11.4",
+          "dependencies": {
+            "form-data": {
+              "version": "0.0.3",
+              "dependencies": {
+                "combined-stream": {
+                  "version": "0.0.3",
+                  "dependencies": {
+                    "delayed-stream": {
+                      "version": "0.0.5"
+                    }
+                  }
+                },
+                "async": {
+                  "version": "0.1.9"
+                }
+              }
+            },
+            "mime": {
+              "version": "1.2.7"
+            }
+          }
+        },
+        "tough-cookie": {
+          "version": "0.9.14",
+          "dependencies": {
+            "punycode": {
+              "version": "1.2.0"
+            }
+          }
+        },
+        "ws": {
+          "version": "0.4.22",
+          "dependencies": {
+            "commander": {
+              "version": "0.6.1"
+            },
+            "tinycolor": {
+              "version": "0.0.1"
+            },
+            "options": {
+              "version": "0.0.3"
+            }
+          }
+        }
+      }
     }
   }
 }

  Modified: package.json (+9 -1)
===================================================================
--- package.json    2012-10-22 15:11:31 +0900 (f7aa47d)
+++ package.json    2012-10-23 18:24:36 +0900 (cdcb018)
@@ -13,14 +13,22 @@
   "bugs": {
     "url": "http://github.com/groonga/gcs-console/issues"
   },
+  "devDependencies": {
+    "mocha": "",
+    "chai": "",
+    "zombie": ""
+  },
   "dependencies": {
     "express": "",
     "jade": "",
     "awssum": "",
     "underscore": "",
-    "connect-flash": ""
+    "connect-flash": "",
+    "mkdirp": "",
+    "rimraf": ""
   },
   "scripts": {
+    "test": "NODE_ENV=test ./node_modules/.bin/mocha --reporter list --ui tdd",
     "start": "./bin/gcs-console"
   },
   "bin": {

  Added: test/index.test.js (+71 -0) 100644
===================================================================
--- /dev/null
+++ test/index.test.js    2012-10-23 18:24:36 +0900 (2ad1fd6)
@@ -0,0 +1,71 @@
+var assert = require('chai').assert;
+var Browser = require('zombie');
+var spawn = require('child_process').spawn;
+var mkdirp = require('mkdirp');
+var rimraf = require('rimraf');
+var fs = require('fs');
+
+// TODO extract these test helpers to another file
+
+function runServer(path, options, callback) {
+  var command = spawn(path, options);
+  command.stdout.on('data', function(data) {
+    if (data.toString().match(/listening/)) {
+      callback();
+    }
+    process.stdout.write(data);
+  });
+  command.stderr.on('data', function(data) {
+    process.stderr.write(data);
+  });
+  return command;
+}
+
+suite('dashboard', function() {
+  var gcs, gcsConsole;
+  var databaseDir = __dirname + '/../test/tmp/gcs';
+  var databasePath = databaseDir + '/gcs';
+  setup(function(done) {
+    var gcsPath = __dirname + '/../node_modules/.bin/gcs';
+    var gcsOptions = [
+      '--database-path', databasePath
+    ]; // TODO set port for gcs
+    var gcsConsolePath = __dirname + '/../bin/gcs-console';
+    var gcsConsoleOptions = []; // TODO set port of gcs and gcs-console
+
+    if (!fs.existsSync(gcsPath)) {
+      var error = new Error('gcs executable is not found at ' + gcsPath + '. You need to setup gcs to test with gcs-console. Run "npm install gcs" (for the latest release) or "npm install git://github.com/groonga/gcs.git" (for the development)');
+      return done(error);
+    }
+
+    mkdirp.sync(databaseDir);
+    gcs = runServer(gcsPath, gcsOptions, function() {
+      gcsConsole = runServer(gcsConsolePath, gcsConsoleOptions, function() {
+        done();
+      })
+    });
+  });
+
+  teardown(function() {
+    if (gcs) {
+      gcs.kill();
+      rimraf.sync(databaseDir);
+    }
+    if (gcsConsole) {
+      gcsConsole.kill();
+    }
+  });
+
+  test('GET /', function(done) {
+    var browser = new Browser();
+    browser.visit('http://localhost:7576'). // TODO make this configurable
+      then(function() {
+        assert.ok(browser.success);
+        assert.equal(browser.text('title'), 'Groonga CloudSearch Console');
+        done();
+      }).
+      fail(function(error) {
+        done(error);
+      });
+  });
+});
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index