1- var assert = require ( "assert" ) ;
21var path = require ( "path" ) ;
3- var Promise = require ( "nodegit-promise " ) ;
2+ var assert = require ( "assert " ) ;
43var promisify = require ( "promisify-node" ) ;
54var fse = promisify ( require ( "fs-extra" ) ) ;
65var local = path . join . bind ( path , __dirname ) ;
7- var fixAppveyor = process . env . APPVEYOR ? describe . skip : describe ;
86
9- fixAppveyor ( "Clone" , function ( ) {
7+ describe ( "Clone" , function ( ) {
108 var http = local ( "../repos/http" ) ;
119 var https = local ( "../repos/https" ) ;
1210 var ssh = local ( "../repos/ssh" ) ;
@@ -24,32 +22,28 @@ fixAppveyor("Clone", function() {
2422 // Set a reasonable timeout here now that our repository has grown.
2523 this . timeout ( 15000 ) ;
2624
27- before ( function ( ) {
28- return Promise . all ( [
29- fse . remove ( http ) ,
30- fse . remove ( https ) ,
31- fse . remove ( ssh ) ,
32- fse . remove ( git ) ,
33- fse . remove ( file ) ,
34- ] ) ;
35- } ) ;
25+ function prepTestAndClean ( url , location , opts ) {
26+ return fse . remove ( location )
27+ . then ( function ( ) {
28+ return Clone . clone ( url , location , opts ) ;
29+ } )
30+ . then ( function ( repo ) {
31+ assert . ok ( repo instanceof Repository ) ;
32+ } ) ;
33+ }
3634
3735 it ( "can clone with http" , function ( ) {
3836 var url = "http://github.com/nodegit/test.git" ;
3937 var opts = { ignoreCertErrors : 1 } ;
4038
41- return Clone . clone ( url , http , opts ) . then ( function ( repository ) {
42- assert . ok ( repository instanceof Repository ) ;
43- } ) ;
39+ return prepTestAndClean ( url , http , opts ) ;
4440 } ) ;
4541
4642 it ( "can clone with https" , function ( ) {
4743 var url = "https://github.com/nodegit/test.git" ;
4844 var opts = { ignoreCertErrors : 1 } ;
4945
50- return Clone . clone ( url , https , opts ) . then ( function ( repository ) {
51- assert . ok ( repository instanceof Repository ) ;
52- } ) ;
46+ return prepTestAndClean ( url , https , opts ) ;
5347 } ) ;
5448
5549 it ( "can clone with ssh" , function ( ) {
@@ -63,9 +57,7 @@ fixAppveyor("Clone", function() {
6357 }
6458 } ;
6559
66- return Clone . clone ( url , ssh , opts ) . then ( function ( repository ) {
67- assert . ok ( repository instanceof Repository ) ;
68- } ) ;
60+ return prepTestAndClean ( url , ssh , opts ) ;
6961 } ) ;
7062
7163 it ( "can clone with ssh while manually loading a key" , function ( ) {
@@ -83,26 +75,20 @@ fixAppveyor("Clone", function() {
8375 }
8476 } ;
8577
86- return Clone . clone ( url , sshManual , opts ) . then ( function ( repository ) {
87- assert . ok ( repository instanceof Repository ) ;
88- } ) ;
78+ return prepTestAndClean ( url , sshManual , opts ) ;
8979 } ) ;
9080
9181 it ( "can clone with git" , function ( ) {
9282 var url = "git://github.com/nodegit/test.git" ;
9383 var opts = { ignoreCertErrors : 1 } ;
9484
95- return Clone . clone ( url , git , opts ) . then ( function ( repository ) {
96- assert . ok ( repository instanceof Repository ) ;
97- } ) ;
85+ return prepTestAndClean ( url , git , opts ) ;
9886 } ) ;
9987
10088 it ( "can clone with filesystem" , function ( ) {
10189 var prefix = process . platform === "win32" ? "" : "file://" ;
10290 var url = prefix + local ( "../repos/empty" ) ;
10391
104- return Clone . clone ( url , file ) . then ( function ( repository ) {
105- assert . ok ( repository instanceof Repository ) ;
106- } ) ;
92+ return prepTestAndClean ( url , file ) ;
10793 } ) ;
10894} ) ;
0 commit comments