Skip to content

Commit 8ec1b13

Browse files
committed
Test for git.fetch
* clone repo * remove tag locally * git fetch origin * verify that tag is back
1 parent a9bdf07 commit 8ec1b13

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/fetch.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
/* global describe, it, after, before, afterEach, beforeEach */
4+
5+
var fs = require('fs');
6+
var rimraf = require('rimraf');
7+
var should = require('should');
8+
var exec = require('child_process').exec;
9+
10+
module.exports = function(git, util){
11+
12+
13+
beforeEach(function(done){
14+
var repo = 'git://github.com/stevelacy/git-test';
15+
git.clone(repo, {args: './test/tmp'}, function(){
16+
exec('git update-ref -d refs/tags/v1.1.1', {cwd: './test/tmp'}, function(err){
17+
if (err) return done(err);
18+
done();
19+
});
20+
});
21+
});
22+
23+
it('should fetch a tag from remote origin', function(done){
24+
git.fetch('origin', '', {cwd: './test/tmp'}, function(){
25+
fs.open('./test/tmp/.git/refs/tags/v1.1.1', 'r', function(err, fd) {
26+
should.not.exist(err);
27+
fs.close(fd, function() {
28+
done();
29+
});
30+
});
31+
});
32+
});
33+
34+
afterEach(function(done){
35+
rimraf('./test/tmp', function(err){
36+
if(err) return done(err);
37+
done();
38+
});
39+
});
40+
};

0 commit comments

Comments
 (0)