git ssb

0+

cel / pull-git-remote-helper



Tree: 280fd5659e55bc23f80c03d64513c47db2dc839b

Files: 280fd5659e55bc23f80c03d64513c47db2dc839b / test / run.js

1900 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
10env.GIT_AUTHOR_DATE = env.GIT_COMMITTER_DATE = '1000000000 -0500'
11var author = 'root <root@localhost>'
12var remote = 'test.js://foo'
13
14var tmpDir = mktemp.createDirSync(path.join(require('os').tmpdir(), 'XXXXXXX'))
15
16function 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
26tape('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
39tape('push with empty repo', function (t) {
40 git('push', remote, function (code) {
41 t.equals(code, 0, 'pushed')
42 t.end()
43 })
44})
45
46tape('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/*
64tape('fetch', function (t) {
65 git('fetch', '-vv', remote, function (code) {
66 t.equals(code, 0, 'fetched')
67 t.end()
68 })
69})
70*/
71
72tape.onFinish(function () {
73 if (tmpDir)
74 rimraf.sync(tmpDir)
75})
76

Built with git-ssb-web