-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fix test setup of autoupgrade/autoupdate #202
Conversation
The two test failures reported by CI are not related to my changes, see #201 |
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.
@bajtos Good catch! I left a comment to simplify the code, while haven't tested them on local, if my comment doesn't work as expected then please ignore it.
Otherwise LGTM 👍
db.once('connected', function() { | ||
originalConnector.cloudant = db.connector.cloudant; | ||
}); | ||
|
||
overrideConnector.automigrate = function(models, cb) { |
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.
If listen on the connected
event before defining the automigrate
and autoupdate
for the overrideConnector
, then if (db.connected)
should be always true
, which means we can simplify the code as
overrideConnector.automigrate = function(models, cb) {
return originalConnector.automigrate(models, cb);
}
overrideConnector.autopdate = function(models, cb) {
return originalConnector.autoupdate(models, cb);
}
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.
If listen on the
connected
event before defining theautomigrate
andautoupdate
for theoverrideConnector
I don't think that's the case. In my understanding, automigrate/autoupdate methods are overwritten at the very beginning, when setting up the datasource, before the datasource has a chance to open the network connection.
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.
The refactor LGTM, please see @jannyHou's comment before
Fix the new test failure observed in loopbackio/loopback-datasource-juggler#1705.
Related issues
Checklist
guide