8000 adding bailout for query instance and test · Pull Request #13 · diegohaz/mongoose-keywords · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

adding bailout for query instance and test #13

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

Merged
merged 5 commits into from Apr 21, 2018
Merged

adding bailout for query instance and test #13

merged 5 commits into from Apr 21, 2018

Conversation

ghost
Copy link
@ghost ghost commented Apr 21, 2018

The details of why I made these changes are in Automattic/mongoose#6375 (comment)

I'm not super familiar with babel or tape, so I won't be offended if you think my changes could be done differently. I'm happy to make any adjustments that you feel it needs.

I hope this helps :)

@ghost
Copy link
Author
ghost commented Apr 21, 2018

I just noticed that when the tests run on mongoose 4, the array that is returned is ordered backwards. I'll have to give this some thought.

just a first pass without refactoring, but something along these lines ought to get it done:

  let found = await Test.findOne({ name: doc.name })
  if (/^4/.test(mongoose.version)) {
    t.same(_.toArray(found.keywords), ['rock', 'test'], 'should work with findone by name')
  } else if (/^5/.test(mongoose.version)){
    t.same(_.toArray(found.keywords), ['test', 'rock'], 'should work with findone by name')
  }

refactored to:

  const found = await Test.findOne({ name: doc.name })
  const arr = ['test', 'rock']
  const major = mongoose.version.charAt(0)
  if(major < 5) {
    arr.sort()
  }

  t.same(_.toArray(found.keywords), arr, 'should work with findone by name')

@diegohaz
Copy link
Owner

Hi, @lineus. Thank you so much for your help. I think the failing tests on CI is due to the use of async/await not being supported by Node < 7.

Could you update .travis.yml to run only v7? (just remove the other versions).

@ghost
Copy link
Author
ghost commented Apr 21, 2018

I removed the async/await and used straight up promises instead. If you'd prefer me to update the travis.yml I can do that instead, but this way I'm not changing your travis setup.

@diegohaz
Copy link
Owner

Great. I think we have finally fixed it. Thank you, @lineus.

@ghost
Copy link
Author
ghost commented Apr 21, 2018

You're very welcome by the way 😀 This was fun to work on! It was neat to play around in your plugin too, I learned several new things from it.

@diegohaz diegohaz merged commit 4e2572f into diegohaz:master Apr 21, 2018
@diegohaz diegohaz mentioned this pull request Apr 21, 2018
@vkarpov15
Copy link

Thanks for fixing this! Don't hesitate to reach out if you have any other issues @diegohaz , we're happy to help 👍

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.

2 participants
0