2018-07-02 23:30:14 -04:00
|
|
|
const auth = require('../lib/Auth');
|
|
|
|
|
const Config = require('../lib/Config');
|
|
|
|
|
const rest = require('../lib/rest');
|
2016-11-02 23:05:23 +00:00
|
|
|
|
|
|
|
|
describe('Enable single schema cache', () => {
|
2018-09-01 13:58:06 -04:00
|
|
|
beforeEach(done => {
|
2016-11-02 23:05:23 +00:00
|
|
|
reconfigureServer({
|
|
|
|
|
enableSingleSchemaCache: true,
|
2018-09-01 13:58:06 -04:00
|
|
|
schemaCacheTTL: 30000,
|
2016-11-02 23:05:23 +00:00
|
|
|
}).then(() => {
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2018-09-01 13:58:06 -04:00
|
|
|
it('can perform multiple create and query operations', done => {
|
2016-11-02 23:05:23 +00:00
|
|
|
let config = fakeRequestForConfig();
|
|
|
|
|
let nobody = auth.nobody(config);
|
2018-09-01 13:58:06 -04:00
|
|
|
rest
|
|
|
|
|
.create(config, nobody, 'Foo', { type: 1 })
|
|
|
|
|
.then(() => {
|
|
|
|
|
config = fakeRequestForConfig();
|
|
|
|
|
nobody = auth.nobody(config);
|
|
|
|
|
return rest.create(config, nobody, 'Foo', { type: 2 });
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
config = fakeRequestForConfig();
|
|
|
|
|
nobody = auth.nobody(config);
|
|
|
|
|
return rest.create(config, nobody, 'Bar');
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
config = fakeRequestForConfig();
|
|
|
|
|
nobody = auth.nobody(config);
|
|
|
|
|
return rest.find(config, nobody, 'Bar', { type: 1 });
|
|
|
|
|
})
|
|
|
|
|
.then(
|
|
|
|
|
() => {
|
|
|
|
|
fail('Should throw error');
|
|
|
|
|
done();
|
|
|
|
|
},
|
|
|
|
|
error => {
|
|
|
|
|
config = fakeRequestForConfig();
|
|
|
|
|
nobody = auth.nobody(config);
|
|
|
|
|
expect(error).toBeDefined();
|
|
|
|
|
return rest.find(config, nobody, 'Foo', { type: 1 });
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
.then(response => {
|
|
|
|
|
config = fakeRequestForConfig();
|
|
|
|
|
nobody = auth.nobody(config);
|
|
|
|
|
expect(response.results.length).toEqual(1);
|
|
|
|
|
done();
|
|
|
|
|
});
|
2016-11-02 23:05:23 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2020-10-25 15:06:58 -05:00
|
|
|
const fakeRequestForConfig = function () {
|
2017-10-23 08:43:05 -04:00
|
|
|
return Config.get('test');
|
2016-11-02 23:05:23 +00:00
|
|
|
};
|