Files: 76d7bd15ac81df893e05f465fa9200b7c1be2e1e / test / run.js
1291 bytesRaw
1 | var spawn = require('child_process').spawn |
2 | var tape = require('tape') |
3 | var path = require('path') |
4 | var mktemp = require('mktemp') |
5 | var rimraf = require('rimraf') |
6 | var fs = require('fs') |
7 | |
8 | var env = Object.create(process.env) |
9 | env.PATH = __dirname + ':' + env.PATH |
10 | var remote = 'test.js://foo' |
11 | |
12 | var tmpDir = mktemp.createDirSync(path.join(require('os').tmpdir(), 'XXXXXXX')) |
13 | |
14 | function git() { |
15 | var args = [].slice.call(arguments) |
16 | var cb = args.pop() |
17 | spawn('git', args, { |
18 | env: env, |
19 | cwd: tmpDir, |
20 | stdio: ['ignore', process.stderr, process.stderr] |
21 | }).on('close', cb) |
22 | } |
23 | |
24 | tape('init repo', function (t) { |
25 | git('init', function (code) { |
26 | t.equals(code, 0, 'inited') |
27 | t.end() |
28 | }) |
29 | }) |
30 | |
31 | tape('make a commit and push', function (t) { |
32 | var filename = path.join(tmpDir, 'blah.txt') |
33 | fs.writeFile(filename, 'i am a file', function (err) { |
34 | t.error(err, 'wrote a file') |
35 | git('add', filename, function (code) { |
36 | t.equals(code, 0, 'added file') |
37 | git('commit', '-mInitial commit', function (code) { |
38 | t.equals(code, 0, 'made initial commit') |
39 | git('push', '-vv', remote, 'master', function (code) { |
40 | t.equals(code, 0, 'pushed') |
41 | t.end() |
42 | }) |
43 | }) |
44 | }) |
45 | }) |
46 | }) |
47 | |
48 | tape.onFinish(function () { |
49 | if (tmpDir) |
50 | rimraf.sync(tmpDir) |
51 | }) |
52 |
Built with git-ssb-web