-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect deleteAll support in KVAO tests #1218
Conversation
bde2a21
to
a09667c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
@@ -11,6 +11,8 @@ module.exports = function(dataSourceFactory, connectorCapabilities) { | |||
let CacheItem; | |||
beforeEach(function unpackContext() { | |||
CacheItem = helpers.givenCacheItem(dataSourceFactory); | |||
if (helpers.connectorSupports('deleteAll', dataSourceFactory)) | |||
return CacheItem.deleteAll(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think we should move CacheItem.deleteAll
into givenCacheItem
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
615f7b1
to
0bab394
Compare
0bab394
to
ff34d25
Compare
return CacheItem; | ||
}; | ||
|
||
exports.givenAnotherModel = function(dataSourceFactory) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's time to create a more generic givenModel
method.
key: String, | ||
value: 'any', | ||
}); | ||
if ('deleteAll' in dataSource.connector) | ||
CacheItem.deleteAll(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to wait until deleteAll
returns before starting the tests.
I think we need to change givenCacheItem
to return a promise now.
exports.givenCacheItem = function(dataSourceFactory) {
// note - most of this code should be moved to `givenModel`
// ...
const p = 'deleteAll' in dataSource.connector ?
CacheItem.deleteAll() : Promise.resolve;
return p.then(() => CacheItem);
};
@@ -11,7 +11,6 @@ module.exports = function(dataSourceFactory, connectorCapabilities) { | |||
let CacheItem; | |||
beforeEach(function unpackContext() { | |||
CacheItem = helpers.givenCacheItem(dataSourceFactory); | |||
return CacheItem.deleteAll(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beforeEach(function unpackContext() {
return helpers.givenCacheItem(dataSourceFactory)
.then(ModelCtor => CacheItem = ModelCtor);
});
@@ -23,12 +23,13 @@ module.exports = function(dataSourceFactory, connectorCapabilities) { | |||
}); | |||
|
|||
it('does not remove data from other existing models', function() { | |||
var AnotherModel = dataSourceFactory().createModel('AnotherModel'); | |||
var AnotherModel = helpers.givenAnotherModel(dataSourceFactory); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
helpers.givenModel(dataSourceFactory, 'AnotherModel')
.then(ModelCtor => {
AnotherModel = ModelCtor;
return helpers.givenKeys(CacheItem, ['key1', 'key2']);
})
.then(() => helpers.givenKeys(AnotherModel, ['key3', 'key4']))
// ...
Write
ebb786f
to
e29c9c7
Compare
beforeEach(function unpackContext() { | ||
CacheItem = helpers.givenCacheItem(dataSourceFactory); | ||
beforeEach(function setupCacheItem() { | ||
helpers.givenCacheItem(dataSourceFactory) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing return
e29c9c7
to
0149c42
Compare
@bajtos PTAL, I assume this is good now? CI fails are unrelated. |
@slnode test please |
Clear CacheItem data between tests if connector supports `deleteAll`. Tests fail with 501 if this check is not used.
0149c42
to
0b93c5c
Compare
@bajtos Gonna land this as everything is passing and I addressed all your concerns in the previous comments so I can test the KVXS PR. |
Follow up issue for oracle fail at loopbackio/loopback-connector-oracle#100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Clear CacheItem data between tests if connector supports
deleteAll
. Tests fail with 501 if this check is not used.