Ghost/test/unit/server/services/adapter-manager/options-resolver.test.js
Naz 5242566252 Added local media storage adapter
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- This is an experimental implementation of video file upload support (audio is yet to follow)
- The storage adapter still needs more thinking as it's almost the same as the "LocalStorgeAdapter" that stores images.
- Also the output serializer skipped use of url utils in favor of inline implementatoin - this should almost certainly be it's own package
2021-11-03 00:33:28 +13:00

75 lines
2.4 KiB
JavaScript

const should = require('should');
const resolveAdapterOptions = require('../../../../../core/server/services/adapter-manager/options-resolver');
describe('Adapter Manager: options resolver', function () {
it('returns default adapter configuration', function () {
const name = 'storage';
const adapterServiceConfig = {
storage: {
active: 'cloud-storage',
'cloud-storage': {
custom: 'configValue'
}
}
};
const {adapterType, adapterName, adapterConfig} = resolveAdapterOptions(name, adapterServiceConfig);
adapterType.should.equal('storage');
adapterName.should.equal('cloud-storage');
adapterConfig.should.deepEqual({
custom: 'configValue'
});
});
it('returns adapter configuration based on specified feature', function () {
const name = 'storage:media';
const adapterServiceConfig = {
storage: {
active: 'cloud-storage',
media: 'local-storage',
'cloud-storage': {
custom: 'configValue'
},
'local-storage': {
custom: 'localStorageConfig'
}
}
};
const {adapterType, adapterName, adapterConfig} = resolveAdapterOptions(name, adapterServiceConfig);
adapterType.should.equal('storage');
adapterName.should.equal('local-storage');
adapterConfig.should.deepEqual({
custom: 'localStorageConfig'
});
});
it('returns active configuration if piece of feature adapter is missing', function () {
const name = 'storage:media';
const adapterServiceConfig = {
storage: {
active: 'cloud-storage',
media: 'local-storage',
'cloud-storage': {
custom: 'configValue'
}
// when you forget to configure local-storage!
// 'local-storage': {
// custom: 'localStorageConfig'
// }
}
};
const {adapterType, adapterName, adapterConfig} = resolveAdapterOptions(name, adapterServiceConfig);
adapterType.should.equal('storage');
adapterName.should.equal('cloud-storage');
adapterConfig.should.deepEqual({
custom: 'configValue'
});
});
});