Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

failing dirmap test

  • Loading branch information...
commit 30c3c8f35853a56da6bc47e559af29201182d632 1 parent 18e4972
@substack authored
Showing with 84 additions and 0 deletions.
  1. +84 −0 test/dirmap.js
View
84 test/dirmap.js
@@ -0,0 +1,84 @@
+var test = require('tap').test;
+var pushover = require('../');
+
+var fs = require('fs');
+var path = require('path');
+var exists = fs.exists || path.exists;
+
+var spawn = require('child_process').spawn;
+var http = require('http');
+
+var seq = require('seq');
+
+test('clone into programatic directories', function (t) {
+ t.plan(3);
+
+ 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);
+ var targetDir = '/tmp/' + Math.floor(Math.random() * (1<<30)).toString(16);
+
+ fs.mkdirSync(repoDir, 0700);
+ fs.mkdirSync(srcDir, 0700);
+ fs.mkdirSync(dstDir, 0700);
+ fs.mkdirSync(targetDir, 0700);
+
+ var repos = pushover(repoDir);
+ var port = Math.floor(Math.random() * ((1<<16) - 1e4)) + 1e4;
+ var server = http.createServer(function (req, res) {
+ repos.handle(req, res);
+ });
+ server.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 (next) {
+ path.exists(targetDir + '/INFO', function (ex) {
+ t.ok(ex, 'INFO exists');
+ next();
+ })
+ })
+ .catch(t.fail)
+ ;
+
+ repos.on('push', function (push) {
+ t.equal(push.repo, 'doom');
+ push.accept(targetDir);
+ });
+
+ t.on('end', function () {
+ server.close();
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.