1 | var assert = require('assert');
|
2 | var download = require('..');
|
3 | var read = require('fs-readdir-recursive');
|
4 | var rm = require('rimraf').sync;
|
5 |
|
6 | describe('download-git-repo', function() {
|
7 | this.timeout(5000);
|
8 | var filter = function(x) {
|
9 | return x[0] !== '.' || x === ".git";
|
10 | };
|
11 |
|
12 | beforeEach(function() {
|
13 | rm('test/tmp');
|
14 | });
|
15 |
|
16 | describe('via github', function() {
|
17 | it('downloads the master branch by default', function(done) {
|
18 | download('github:zeke/download-github-repo-fixture', 'test/tmp', function(err) {
|
19 | if (err) return done(err);
|
20 | var actual = read('test/tmp', filter);
|
21 | var expected = read('test/fixtures/master');
|
22 | assert.deepEqual(actual, expected);
|
23 | done();
|
24 | });
|
25 | });
|
26 |
|
27 | it('download branches too', function(done) {
|
28 | download('github:zeke/download-github-repo-fixture#my-branch', 'test/tmp', function(err) {
|
29 | if (err) return done(err);
|
30 | var actual = read('test/tmp', filter);
|
31 | var expected = read('test/fixtures/my-branch');
|
32 | assert.deepEqual(actual, expected);
|
33 | done();
|
34 | });
|
35 | });
|
36 |
|
37 | it('downloads from github by default', function(done) {
|
38 | download('zeke/download-github-repo-fixture', 'test/tmp', function(err) {
|
39 | if (err) return done(err);
|
40 | var actual = read('test/tmp', filter);
|
41 | var expected = read('test/fixtures/master');
|
42 | assert.deepEqual(actual, expected);
|
43 | done();
|
44 | });
|
45 | });
|
46 |
|
47 | it('clones the master branch by default', function(done) {
|
48 | download('github:zeke/download-github-repo-fixture', 'test/tmp', { clone: true }, function(err) {
|
49 | if (err) return done(err);
|
50 | var actual = read('test/tmp', filter);
|
51 | var expected = read('test/fixtures/master');
|
52 | assert.deepEqual(actual, expected);
|
53 | done();
|
54 | });
|
55 | });
|
56 |
|
57 | it('clones branches too', function(done) {
|
58 | download('github:zeke/download-github-repo-fixture#my-branch', 'test/tmp', { clone: true }, function(err) {
|
59 | if (err) return done(err);
|
60 | var actual = read('test/tmp', filter);
|
61 | var expected = read('test/fixtures/my-branch');
|
62 | assert.deepEqual(actual, expected);
|
63 | done();
|
64 | });
|
65 | });
|
66 | });
|
67 |
|
68 | describe('via bitbucket', function() {
|
69 | it('downloads the master branch by default', function(done) {
|
70 | download('bitbucket:flipxfx/download-bitbucket-repo-fixture', 'test/tmp', function(err) {
|
71 | if (err) return done(err);
|
72 | var actual = read('test/tmp', filter);
|
73 | var expected = read('test/fixtures/master');
|
74 | assert.deepEqual(actual, expected);
|
75 | done();
|
76 | });
|
77 | });
|
78 |
|
79 | it('download branches too', function(done) {
|
80 | download('bitbucket:flipxfx/download-bitbucket-repo-fixture#my-branch', 'test/tmp', function(err) {
|
81 | if (err) return done(err);
|
82 | var actual = read('test/tmp', filter);
|
83 | var expected = read('test/fixtures/my-branch');
|
84 | assert.deepEqual(actual, expected);
|
85 | done();
|
86 | });
|
87 | });
|
88 |
|
89 | it('clones the master branch by default', function(done) {
|
90 | download('bitbucket:flipxfx/download-bitbucket-repo-fixture', 'test/tmp', { clone: true }, function(err) {
|
91 | if (err) return done(err);
|
92 | var actual = read('test/tmp', filter);
|
93 | var expected = read('test/fixtures/master');
|
94 | assert.deepEqual(actual, expected);
|
95 | done();
|
96 | });
|
97 | });
|
98 |
|
99 | it('clones branches too', function(done) {
|
100 | download('bitbucket:flipxfx/download-bitbucket-repo-fixture#my-branch', 'test/tmp', { clone: true }, function(err) {
|
101 | if (err) return done(err);
|
102 | var actual = read('test/tmp', filter);
|
103 | var expected = read('test/fixtures/my-branch');
|
104 | assert.deepEqual(actual, expected);
|
105 | done();
|
106 | });
|
107 | });
|
108 | });
|
109 | });
|