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

Breaking Change in loading test data #30

Open
AlexanderPruss opened this issue Jan 7, 2020 · 2 comments
Open

Breaking Change in loading test data #30

AlexanderPruss opened this issue Jan 7, 2020 · 2 comments

Comments

@AlexanderPruss
Copy link
Contributor

h1. Problem:

In version 1.4.4, you could load an individual test object into mongo unit. Suppose I had an object named object -

//This used to be ok
await mongoUnit.load({ "collection": {...object});

In the current version 1.5.1, load has been changed to use insertMany instead of just insert - here's the position in the code. 06d131f#diff-168726dbe96b3ce427e7fedce31bb0bcL73-R84

This means that the same call as before no longer works. The correct way to send in a single test object is now

//This is now required
await mongoUnit.load({"collection": [{...object}]);


h1. Solutions

At minimum, we should mention this in the ReadMe and consider adding it as a javadoc-style comment to the load function. The load function could also check to see if the object it received is an array, and decide whether to use insert or insertMany depending on that. I'm happy with making either of these changes for you.

Great tool, by the way! :)

@AlexanderPruss
Copy link
Contributor Author

The change making mongoUnit.start() no longer return a URL is also breaking, incidentally

@mikhail-angelov
Copy link
Owner

mikhail-angelov commented Jan 8, 2020

Thank you for comment @AlexanderPruss
you are right, I braked it a bit once I update mongo driver

I'm happy with making either of these changes for you.

it will be great and I'll release 2.0.0
I think the better solution will be just update documentation and make API always expect array as input param (less variability is always better for stability)

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

No branches or pull requests

2 participants