Files: 280fd5659e55bc23f80c03d64513c47db2dc839b / test / run.js
1900 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 | env.GIT_AUTHOR_DATE = env.GIT_COMMITTER_DATE = '1000000000 -0500' |
11 | var author = 'root <root@localhost>' |
12 | var remote = 'test.js://foo' |
13 | |
14 | var tmpDir = mktemp.createDirSync(path.join(require('os').tmpdir(), 'XXXXXXX')) |
15 | |
16 | function git() { |
17 | var args = [].slice.call(arguments) |
18 | var cb = args.pop() |
19 | spawn('git', args, { |
20 | env: env, |
21 | cwd: tmpDir, |
22 | stdio: ['ignore', process.stderr, process.stderr] |
23 | }).on('close', cb) |
24 | } |
25 | |
26 | tape('init repo', function (t) { |
27 | git('init', function (code) { |
28 | t.equals(code, 0, 'inited') |
29 | git('config', 'user.name', 'test', function (code) { |
30 | t.equals(code, 0, 'set user name') |
31 | git('config', 'user.email', 'test@localhost', function (code) { |
32 | t.equals(code, 0, 'set user email') |
33 | t.end() |
34 | }) |
35 | }) |
36 | }) |
37 | }) |
38 | |
39 | tape('push with empty repo', function (t) { |
40 | git('push', remote, function (code) { |
41 | t.equals(code, 0, 'pushed') |
42 | t.end() |
43 | }) |
44 | }) |
45 | |
46 | tape('make a commit and push', function (t) { |
47 | var filename = path.join(tmpDir, 'blah.txt') |
48 | fs.writeFile(filename, 'i am a file', function (err) { |
49 | t.error(err, 'wrote a file') |
50 | git('add', filename, function (code) { |
51 | t.equals(code, 0, 'added file') |
52 | git('commit', '-mInitial commit', function (code) { |
53 | t.equals(code, 0, 'made initial commit') |
54 | git('push', '-vv', remote, 'master', function (code) { |
55 | t.equals(code, 0, 'pushed') |
56 | t.end() |
57 | }) |
58 | }) |
59 | }) |
60 | }) |
61 | }) |
62 | |
63 | /* |
64 | tape('fetch', function (t) { |
65 | git('fetch', '-vv', remote, function (code) { |
66 | t.equals(code, 0, 'fetched') |
67 | t.end() |
68 | }) |
69 | }) |
70 | */ |
71 | |
72 | tape.onFinish(function () { |
73 | if (tmpDir) |
74 | rimraf.sync(tmpDir) |
75 | }) |
76 |
Built with git-ssb-web