git ssb

0+

cel / pull-git-remote-helper



Tree: 95a067249e90995c9d34e46ae4aa937180c1d2f6

Files: 95a067249e90995c9d34e46ae4aa937180c1d2f6 / test / run.js

1565 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('push with empty repo', function (t) {
32 git('push', remote, function (code) {
33 t.equals(code, 0, 'pushed')
34 t.end()
35 })
36})
37
38tape('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/*
56tape('fetch', function (t) {
57 git('fetch', '-vv', remote, function (code) {
58 t.equals(code, 0, 'fetched')
59 t.end()
60 })
61})
62*/
63
64tape.onFinish(function () {
65 if (tmpDir)
66 rimraf.sync(tmpDir)
67})
68

Built with git-ssb-web