2018-09-17 16:00:12 +00:00
|
|
|
// Copyright IBM Corp. 2013,2016. All Rights Reserved.
|
|
|
|
// Node module: loopback-datasource-juggler
|
|
|
|
// This file is licensed under the MIT License.
|
|
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
|
2016-08-08 08:15:22 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-12-07 14:54:29 +00:00
|
|
|
const debug = require('debug')('test');
|
|
|
|
const extend = require('util')._extend;
|
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
2016-08-08 08:15:22 +00:00
|
|
|
|
|
|
|
module.exports = function(dataSourceFactory, connectorCapabilities) {
|
2016-10-07 14:26:18 +00:00
|
|
|
connectorCapabilities = extend({
|
|
|
|
// Even when the backend supports millisecond precision,
|
|
|
|
// it's better to use intervals at least 10ms long in the tests
|
|
|
|
ttlPrecision: 10,
|
|
|
|
}, connectorCapabilities);
|
|
|
|
|
2016-08-08 08:15:22 +00:00
|
|
|
describe('KeyValue API', function loadAllTestFiles() {
|
2018-12-07 14:54:29 +00:00
|
|
|
const testRoot = path.resolve(__dirname, 'kvao');
|
|
|
|
let testFiles = fs.readdirSync(testRoot);
|
2016-08-08 08:15:22 +00:00
|
|
|
testFiles = testFiles.filter(function(it) {
|
|
|
|
return !!require.extensions[path.extname(it).toLowerCase()] &&
|
|
|
|
/\.suite\.[^.]+$/.test(it);
|
|
|
|
});
|
|
|
|
|
2018-12-07 14:54:29 +00:00
|
|
|
for (const ix in testFiles) {
|
|
|
|
const name = testFiles[ix];
|
|
|
|
const fullPath = path.resolve(testRoot, name);
|
2016-08-08 08:15:22 +00:00
|
|
|
debug('Loading test suite %s (%s)', name, fullPath);
|
|
|
|
require(fullPath)(dataSourceFactory, connectorCapabilities);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|