-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
116 lines (114 loc) · 3.18 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
var assert = require('assert'),
lib = require('./index'),
fs = require('fs'),
rimraf = require('rimraf');
describe('lib', function(){
it('should throw errors', function(done){
lib.download({}, function(err){
assert.equal(err.toString(), 'Error: Missing url destination');
done();
});
});
it('should throw errors', function(done){
lib.download({url:'www.google.com'}, function(err){
assert.equal(err.toString(), 'Error: Missing file name');
done();
});
});
it('should download the specified file', function(done){
lib.download({
url:'http://downloads.basho.com.s3-website-us-east-1.amazonaws.com/riak/1.3/1.3.0/riak-1.3.0.tar.gz',
fileName:'riak-1.3.0.tar.gz',
disco: true
}, function(err){
assert.equal(err, null);
fs.exists('riak-1.3.0.tar.gz', function(exists){
assert.ok(exists);
done();
});
});
});
it('should throw errors', function(done){
lib.extract({}, function(err){
assert.equal(err.toString(), 'Error: Missing file name');
done();
});
});
it('should throw errors', function(done){
lib.extract({fileName:'blah'}, function(err){
assert.equal(err.toString(), 'Error: Missing destination');
done();
});
});
it('should extract the specified file', function(done){
lib.extract({
fileName:'riak-1.3.0.tar.gz',
dest:'./'
}, function(err){
assert.equal(err, null);
fs.exists('riak-1.3.0', function(exists){
assert.ok(exists);
lib.extract({
fileName: 'riak-1.3.0.tar.gz',
dest:'./'
}, function(err){
assert.equal('Error: output directory exists and could be written over', err);
done();
});
});
});
});
it('should make all', function(done){
lib.build({
dir:'riak-1.3.0',
fake:true
}, function(err){
assert.equal(err, null);
fs.exists('./riak-1.3.0/rel/riak/bin/riak', function(exists){
assert.ok(exists);
done();
});
});
});
it('should list available versions', function(done){
lib.listVersions({url:'http://downloads.basho.com.s3-website-us-east-1.amazonaws.com/riak/'}, function(err, list){
assert.equal(err, null);
assert.equal(list.length > 0, true);
done();
});
});
after(function(done){
rimraf('./riak-1.3.0', function(error){
fs.unlink('./riak-1.3.0.tar.gz', function(){
fs.exists('./riak-1.3.0', function(exists){
assert.equal(exists, false);
fs.exists('riak-1.3.0.tar.gz', function(exists){
assert.equal(exists, false);
done();
});
});
});
});
});
});
describe('bin', function() {
var cp = require('child_process').spawn;
it('should output --help with no options', function(done){
function run(a, cb) {
var data = "";
cp('./riakvm', a)
.stdout.on('data', function(d) {
data += d.toString();
})
.on('close', function() {
cb(null, data);
});
}
run([], function(err, data1) {
run(['--help'], function(err, data2) {
assert.equal(data1, data2);
done();
});
});
});
});