-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathstorage-object-metadata-test.js
More file actions
89 lines (85 loc) · 2.54 KB
/
storage-object-metadata-test.js
File metadata and controls
89 lines (85 loc) · 2.54 KB
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
/*
* container-test.js: Tests for Rackspace Cloudfiles containers
*
* (C) 2010 Nodejitsu Inc.
* MIT LICENSE
*
*/
var path = require('path'),
vows = require('vows'),
fs = require('fs'),
assert = require('assert'),
cloudfiles = require('../lib/cloudfiles'),
helpers = require('./helpers');
var testData = {},
client = helpers.createClient(),
sampleData = fs.readFileSync(path.join(__dirname, '..', 'test', 'fixtures', 'fillerama.txt')).toString();
vows.describe('node-cloudfiles/storage-object').addBatch(helpers.requireAuth(client)).addBatch({
"The node-cloudfiles client": {
"an instance of a Container object": {
"the addFile() method": {
topic: function () {
var ustream = client.addFile('test_container', {
remote: 'file1.txt',
local: path.join(__dirname, '..', 'test', 'fixtures', 'fillerama.txt')
}, function () { });
ustream.on('end', this.callback)
},
"should raise the `end` event": function () {
assert.isTrue(true);
}
}
}
}
}).addBatch({
"The node-cloudfiles client": {
"the getFile() method": {
"for a file that exists": {
topic: function () {
client.getFile('test_container', 'file1.txt', this.callback);
},
"should return a valid StorageObject": function (err, file) {
helpers.assertFile(file);
testData.file = file;
}
}
}
}
}).addBatch({
"The node-cloudfiles client": {
"the addMetadata() method": {
topic: function () {
testData.metadata = { "ninja-metadata": "true" };
testData.file.addMetadata(testData.metadata, this.callback);
},
"should response with true": function (err, added) {
assert.isTrue(added);
assert.deepEqual(testData.file.metadata, testData.metadata);
}
}
}
}).addBatch({
"The node-cloudfiles client": {
"the getMetadata() method": {
topic: function () {
testData.file.getMetadata(this.callback);
},
"should return the metadata as an object": function (err, metadata) {
assert.deepEqual(metadata, testData.metadata);
}
}
}
}).addBatch({
"The node-cloudfiles client": {
"the destroyFile() method": {
"for a file that exists": {
topic: function () {
client.destroyFile('test_container', 'file1.txt', this.callback);
},
"should return true": function (err, deleted) {
assert.isTrue(deleted);
}
}
}
}
}).export(module);