/
zip-test.js
99 lines (89 loc) · 2.15 KB
/
zip-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
/*
* zip-test.js: Tests for Zip repository.
*
* (C) 2010, Nodejitsu Inc.
*
*/
var assert = require('assert'),
path = require('path'),
eyes = require('eyes'),
vows = require('vows'),
helpers = require('../helpers'),
haibu = require('../../lib/haibu');
var ipAddress = '127.0.0.1',
port = 9000,
config = helpers.loadConfig(true),
cloudfilesApp,
httpApp;
httpApp = {
"name": "test",
"user": "marak",
"repository": {
"type": "zip",
"protocol": "http",
"url": "http://c0027507.cdn1.cloudfiles.rackspacecloud.com/hellonode.zip"
},
"scripts": {
"start": "server.js"
}
};
cloudfilesApp = {
"name": "test",
"user": "charlie",
"repository": {
"type": "zip",
"protocol": "cloudfiles",
"filename": "hellonode.zip",
"container": "nodejitsu-apps",
"auth": config.auth
},
"scripts": {
"start": "server.js"
}
};
// Create the vows test suite
var suite = vows.describe('haibu/repositories/zip').addBatch(
helpers.requireInit()
);
//
// Iterate over the two remote types we wish to execute
// identical tests for.
//
[httpApp, cloudfilesApp].forEach(function (app) {
var remoteType = (app === httpApp) ? "http" : "cloudfiles";
var tests = {};
tests["with an " + remoteType + " remote"] = {
topic: function () {
return haibu.repository.create(app);
},
"should be a valid repository": function (zip) {
assert.equal(haibu.repository.validate(zip.app).valid, true);
assert.isFunction(zip.init);
assert.isFunction(zip.exists);
assert.isFunction(zip.update);
assert.isFunction(zip.fetchHttp);
assert.isFunction(zip.fetchCloudfiles);
},
"the init() method": {
topic: function (zip) {
zip.init(this.callback);
},
"should unzip to the specified location": function (err, success, files) {
assert.isNull(err);
assert.isArray(files);
}
}
};
var batch = {
"When using haibu": {
"an instance of the Zip repository": tests
}
};
suite.addBatch(batch);
});
if (helpers.auth) {
//
// If there is no config file, we can't run the remote tests
//
suite.export(module);
}