Files: 95a067249e90995c9d34e46ae4aa937180c1d2f6 / test / run.js
1565 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('push with empty repo', function (t) { |
32 | git('push', remote, function (code) { |
33 | t.equals(code, 0, 'pushed') |
34 | t.end() |
35 | }) |
36 | }) |
37 | |
38 | tape('make a commit and push', function (t) { |
39 | var filename = path.join(tmpDir, 'blah.txt') |
40 | fs.writeFile(filename, 'i am a file', function (err) { |
41 | t.error(err, 'wrote a file') |
42 | git('add', filename, function (code) { |
43 | t.equals(code, 0, 'added file') |
44 | git('commit', '-mInitial commit', function (code) { |
45 | t.equals(code, 0, 'made initial commit') |
46 | git('push', '-vv', remote, 'master', function (code) { |
47 | t.equals(code, 0, 'pushed') |
48 | t.end() |
49 | }) |
50 | }) |
51 | }) |
52 | }) |
53 | }) |
54 | |
55 | /* |
56 | tape('fetch', function (t) { |
57 | git('fetch', '-vv', remote, function (code) { |
58 | t.equals(code, 0, 'fetched') |
59 | t.end() |
60 | }) |
61 | }) |
62 | */ |
63 | |
64 | tape.onFinish(function () { |
65 | if (tmpDir) |
66 | rimraf.sync(tmpDir) |
67 | }) |
68 |
Built with git-ssb-web