Skip to content

Commit 3a3052c

Browse files
authored
Announce to client that FileStore supports termination extension (#261)
1 parent 2cba491 commit 3a3052c

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

lib/stores/DataStore.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class DataStore extends EventEmitter {
4242
this._extensions = extensions_array;
4343
}
4444

45+
hasExtension(extension) {
46+
return this._extensions.indexOf(extension) !== -1;
47+
}
48+
4549
/**
4650
* Called in POST requests. This method just creates a
4751
* file, implementing the creation extension.

lib/stores/FileStore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class FileStore extends DataStore {
2626
super(options);
2727
this.directory = options.directory || options.path.replace(/^\//, '');
2828

29-
this.extensions = ['creation', 'creation-with-upload', 'creation-defer-length'];
29+
this.extensions = ['creation', 'creation-with-upload', 'creation-defer-length', 'termination'];
3030
this.configstore = new Configstore(`${pkg.name}-${pkg.version}`);
3131
this._checkOrCreateDirectory();
3232
}

test/Test-DataStore.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ describe('DataStore', () => {
4141
done();
4242
});
4343

44+
it('should check for an extension', (done) => {
45+
datastore.extensions = [ 'creation', 'expiration'];
46+
assert.equal(datastore.hasExtension('creation'), true);
47+
assert.equal(datastore.hasExtension('expiration'), true);
48+
49+
assert.equal(datastore.hasExtension('concatentation'), false);
50+
assert.equal(datastore.hasExtension('CREATION'), false); // test case sensitivity
51+
done();
52+
});
53+
4454
it('must have a create method', (done) => {
4555
datastore.should.have.property('create');
4656
datastore.create.should.be.type('function');

test/Test-Stores.shared.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ exports.shouldCreateUploads = function () {
5050
url: this.storePath,
5151
}
5252

53+
it('should report \'creation\' extension', function () {
54+
assert.equal(this.server.datastore.hasExtension('creation'), true);
55+
})
56+
5357
it('should reject if both upload-length and upload-defer-length are not provided', function (done) {
5458
assert.rejects(() => this.server.datastore.create(invalidReq))
5559
done()
@@ -88,6 +92,10 @@ exports.shouldCreateUploads = function () {
8892

8993
exports.shouldRemoveUploads = function () {
9094
describe('remove (termination extension)', function () {
95+
it('should report \'termination\' extension', function () {
96+
assert.equal(this.server.datastore.hasExtension('termination'), true);
97+
})
98+
9199
it('should reject when the file does not exist', function () {
92100
const req = { file_id: '1234' }
93101
return this.server.datastore.remove(req).should.be.rejected()

0 commit comments

Comments
 (0)