Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

CRUD unit test not passing #1124

Closed
JulianLaval opened this issue Dec 31, 2015 · 9 comments
Closed

CRUD unit test not passing #1124

JulianLaval opened this issue Dec 31, 2015 · 9 comments
Assignees
Milestone

Comments

@JulianLaval
Copy link
Contributor

Hi there,

I just yesterday cloned the MEANJS repo and installed the latest version of MongoDB on my Windows 10 machine.

Running the grunt test:server task throws an AssertionError when it gets to User CRUD tests should not be able to update own user details with existing username as well as for an existing email.

In particular:

Username already exists was expected
11000 duplicate key error collection: mean-test.users index: username already exists was received

Digging around in the code, I found the following line in the getUniqueErrorMessage method in modules/core/server/controllers/errors.server.controller.js which should indeed fetch the actual field name:

var fieldName = err.errmsg.substring(err.errmsg.lastIndexOf('.$') + 2, err.errmsg.lastIndexOf('_1'));

The search for an index of .$ seems to corroborate the error MongoDB has thrown in the past, e.g.:

E11000 duplicate key error index: mydb.users.$email_1 dup key: { : null }

Source

Can anyone reproduce this? Could it be that the test case simply isn't up to date with the latest releases of Mongoose/MongoDB? I'm happy to submit a PR if so, although I would suspect it be a breaking change for users still on an older version of Mongo.

Cheers!

@lirantal
Copy link
Member

lirantal commented Jan 2, 2016

Is that reproducible only on your Windows machine?
Our linux-based builds are passing just fine with latest PRs.

Can you specify the installed mongodb version you have?

@JulianLaval
Copy link
Contributor Author

MongoDB version is the latest stable release, 3.2.0.

I am indeed unsure whether this is a Windows issue (I don't have access to a Linux distro on which to reproduce it), or a change introduced in the latest Mongo release? The latter would make more sense, as I don't see why they would change the error syntax based on the OS...

@rhutchison
Copy link
Contributor

I am having the same issue on Windows 10 with mongodb 3.2.0

@JulianLaval
Copy link
Contributor Author

Right, have gotten around to testing it on Ubuntu 14.04, also MongoDB v3.2.0, and the errors are as expected:

'E11000 duplicate key error index: mydb.users.$email_1 dup key: { : "test@test.com" }'

Definitely a Windows issue!

@mleanos
Copy link
Member

mleanos commented Jan 4, 2016

It's not a Windows issue, nor a Windows 10 issue. I've been using this project on Windows 7, for quite some time, and haven't ran into this issue.

I just got a Windows 10 environment setup, and it's working for me there as well..
MongoDB: 3.0.8
Node: 4.2.4
NPM: 2.14.12

My guess is that it's the MongoDB version that is causing the issue. It could also be a mongoose issue. Can you share what versions of Node, NPM, and Mongoose you have installed?

I may try to bump up my MongoDB version to match both of yours.

@JulianLaval
Copy link
Contributor Author

Downgrading to MongoDB 3.0.8 solved the issue, cheers!

Does anything need to be done wrt. 3.2.0 support on Windows? The same version works correctly on Ubuntu 14.04...

@mleanos
Copy link
Member

mleanos commented Jan 4, 2016

It's hard to tell what the issue might be with that version of MongoDB & Windows 10; without extensive investigation. It could be a mongoose issue as well.

We'd probably want to test with Windows 7 as well. There might be some useful info/discussions in Mongo's repo. That's probably the best place to start.

@mcalhoun
Copy link

Just to add to this...I'm seeing the same behavior on MacOS 10.11.2 with mongo 3.2.1 installed via Homebrew...

$ mongod --version
db version v3.2.1
git version: a14d55980c2cdc565d4704a7e3ad37e4e535c1b2
allocator: system
modules: none
build environment:
distarch: x86_64
target_arch: x86_64

@Wuntenn
Copy link
Contributor

Wuntenn commented Jan 28, 2016

I had this issue a few times on ubuntu virtualised servers. Where there are no dependency issues I didn't see this, however where I installed and had issues with kerberos and ignored them running grunt server etc I saw this error repeatedly (by "repeatedly" I mean on different provisioned ubuntu instances (rather than the same instance re-issued with the same commands! :D))

Try installing node via nvm: I haven't seen half the issues since going this route!

It could be related to default npm global prefix which nvm manages per node installed version.

rhutchison added a commit to Gym/mean that referenced this issue Feb 10, 2016
…ersions of mongodb.

When running a newer version of mongodb, users are reporting an issue when executing tests because the response from the mongo request has changed.  This change should support new/old versions of the test.

Resolves meanjs#1124
@lirantal lirantal added this to the 0.5.0 milestone Feb 13, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants