Permalink
Browse files

Tests

  • Loading branch information...
1 parent 87c092f commit 3319fa490e90b82efd1fdfb704a059d9e8cdf222 @bencevans committed Oct 7, 2012
Showing with 61 additions and 3 deletions.
  1. +5 −1 app.js
  2. +2 −2 index.html
  3. +54 −0 test.js
View
@@ -74,4 +74,8 @@ var server = http.createServer(function (req, res) {
});
-server.listen(config.port);
+if (!module.parent) {
+ server.listen(config.port);
+} else {
+ module.exports = server;
+}
View
@@ -55,9 +55,9 @@
{{#if gitURL}}
<p>Your Git Repo Container will collapse in <span id="timeLeft">900</span> seconds!</p>
<h2>You:</h2>
- <div class="terminal">git push {{gitURL}} master</div><br/>
+ <div class="terminal" id="push">git push {{gitURL}} master</div><br/>
<h2>Friend:</h2>
- <div class="terminal">git clone {{gitURL}} master</div>
+ <div class="terminal" id="clone">git clone {{gitURL}}</div>
{{else}}
<form method="POST" action="/">
<input type=submit value="Generate Git Repo Container">
View
@@ -0,0 +1,54 @@
+
+var assert = require('assert')
+, spawn = require('child_process').spawn
+, request = require('request')
+, cheerio = require('cheerio')
+, freeport = require('freeport')
+, forever = require('forever-monitor');
+
+describe('QuickGit', function (){
+
+ var pushCommand;
+ var cloneCommand;
+ var quickGitInstance;
+ var quickGitURL;
+
+ before(function (done) {
+
+ this.timeout = 5000;
+
+ freeport(function(err, port) {
+ if (err) return assert.equal(null, err);
+
+ quickGitInstance = require('./app.js');
+ assert.ok(quickGitInstance);
+
+ quickGitInstance.listen(port);
+ quickGitURL = 'http://127.0.0.1:' + port
+
+ done();
+ })
+
+ });
+
+ it('provide a push and clone command', function (done) {
+ request({url:quickGitURL, method:'POST'}, function (err, res, body) {
+ if(err) return done(err);
+
+ var $ = cheerio.load(body);
+
+ pushCommand = $('#push').html();
+ assert.ok(pushCommand.match(/^git push https?:\/\/.+:[0-9]+\/.+\.git master$/));
+
+ cloneCommand = $('#clone').html();
+ assert.ok(cloneCommand.match(/^git clone https?:\/\/.+:[0-9]+\/.+\.git$/));
+
+ done();
+ });
+ });
+
+ it('should accept a push and a clone');
+
+ it('should decline a push if container isn\'t created');
+
+});

0 comments on commit 3319fa4

Please sign in to comment.