forked from quickredfox/pushover
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
James Halliday
committed
Nov 23, 2011
1 parent
3eff84a
commit b664978
Showing
2 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
var test = require('tap').test; | ||
var pushover = require('../'); | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
var spawn = require('child_process').spawn; | ||
|
||
var seq = require('seq'); | ||
|
||
test('create, push to, and clone a repo', function (t) { | ||
t.plan(2); | ||
|
||
var repoDir = '/tmp/' + Math.floor(Math.random() * (1<<30)).toString(16); | ||
var srcDir = '/tmp/' + Math.floor(Math.random() * (1<<30)).toString(16); | ||
var dstDir = '/tmp/' + Math.floor(Math.random() * (1<<30)).toString(16); | ||
|
||
fs.mkdirSync(repoDir, 0700); | ||
fs.mkdirSync(srcDir, 0700); | ||
fs.mkdirSync(dstDir, 0700); | ||
|
||
var repos = pushover(repoDir); | ||
var port = Math.floor(Math.random() * ((1<<16) - 1e4)) + 1e4; | ||
var server = repos.listen(port); | ||
|
||
process.chdir(srcDir); | ||
seq() | ||
.seq(function () { | ||
var ps = spawn('git', [ 'init' ]); | ||
ps.stderr.pipe(process.stderr, { end : false }); | ||
ps.on('exit', this.ok); | ||
}) | ||
.seq(function () { | ||
fs.writeFile(srcDir + '/a.txt', 'abcd', this); | ||
}) | ||
.seq(function () { | ||
spawn('git', [ 'add', 'a.txt' ]).on('exit', this.ok) | ||
}) | ||
.seq(function () { | ||
spawn('git', [ 'commit', '-am', 'a!!' ]).on('exit', this.ok) | ||
}) | ||
.seq(function () { | ||
var ps = spawn('git', [ | ||
'push', 'http://localhost:' + port + '/doom', 'master' | ||
]); | ||
ps.stderr.pipe(process.stderr, { end : false }); | ||
ps.on('exit', this.ok); | ||
}) | ||
.seq(function () { | ||
process.chdir(dstDir); | ||
spawn('git', [ 'clone', 'http://localhost:' + port + '/doom' ]) | ||
.on('exit', this.ok) | ||
}) | ||
.seq_(function (next) { | ||
path.exists(dstDir + '/doom/a.txt', function (ex) { | ||
t.ok(ex, 'a.txt exists'); | ||
next(); | ||
}) | ||
}) | ||
.seq(function () { | ||
server.close(); | ||
t.end(); | ||
}) | ||
.catch(t.fail) | ||
; | ||
|
||
repos.on('push', function (repo) { | ||
t.equal(repo, 'doom'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters