Skip to content
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

Merged
merged 1 commit into from
Apr 9, 2019
Merged

Conversation

bajtos
Copy link
Member

@bajtos bajtos commented Apr 8, 2019

Fix the new test failure observed in loopbackio/loopback-datasource-juggler#1705.

Related issues

Checklist

  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style
    guide

@bajtos
Copy link
Member Author

bajtos commented Apr 8, 2019

The two test failures reported by CI are not related to my changes, see #201

Copy link
Contributor

@jannyHou jannyHou left a 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) {
Copy link
Contributor

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);
}

Copy link
Member Author

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

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.

Copy link
Contributor

@b-admike b-admike left a 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 :shipit:

@bajtos bajtos merged commit ab7688e into master Apr 9, 2019
@bajtos bajtos deleted the fix/autoupdate-in-tests branch April 9, 2019 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants