git ssb

0+

cel / pull-git-remote-helper



Tree: 76d7bd15ac81df893e05f465fa9200b7c1be2e1e

Files: 76d7bd15ac81df893e05f465fa9200b7c1be2e1e / test / run.js

1291 bytesRaw
1var spawn = require('child_process').spawn
2var tape = require('tape')
3var path = require('path')
4var mktemp = require('mktemp')
5var rimraf = require('rimraf')
6var fs = require('fs')
7
8var env = Object.create(process.env)
9env.PATH = __dirname + ':' + env.PATH
10var remote = 'test.js://foo'
11
12var tmpDir = mktemp.createDirSync(path.join(require('os').tmpdir(), 'XXXXXXX'))
13
14function 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
24tape('init repo', function (t) {
25 git('init', function (code) {
26 t.equals(code, 0, 'inited')
27 t.end()
28 })
29})
30
31tape('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
48tape.onFinish(function () {
49 if (tmpDir)
50 rimraf.sync(tmpDir)
51})
52

Built with git-ssb-web