-
Notifications
You must be signed in to change notification settings - Fork 7
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
Closes #78 Add support to specify seeds to be created at server start up #80
Conversation
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.
It looks good with good coverage. I have some comments - some minor some are pretty crucial.
src/utils.js
Outdated
projectsToCreate = []; | ||
|
||
|
||
Q.ninvoke(storage, 'getProjects', {}) |
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.
Doesn't storage.getProjects
already return a promise? More importantly the user isn't specified and would only return guest's projects..
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 user should be the creator (as it would have access to the owners projects too).
src/utils.js
Outdated
existingProjectIds.push(projectInfo._id); | ||
}); | ||
|
||
(gmeConfig.seedProjects.createAtStartup || []).forEach(function (projectInfo) { |
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.
You already check in the validator that this is an array..
src/utils.js
Outdated
} | ||
|
||
|
||
return Q.ninvoke(gmeAuth, 'listUsers', null); |
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.
Again - this returns a promise...
src/utils.js
Outdated
logger.error('Cannot create project [' + projectInfo.id + '] as creator [' + | ||
projectInfo.creatorId + '] is missing!'); | ||
projectInfo.failed = true; | ||
promises.push(null); |
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.
Does null
really work well with Q.all ?
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.
Nm, it looks like the tests covers that 👍
However I think an error here should fail and halt the startup process..
.nodeify(done); | ||
}); | ||
|
||
it('should not create startup projects that has bad creator assigned to it', function (done) { |
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.
Shouldn't this resolve with error?
src/utils.js
Outdated
|
||
tokens = tokens_; | ||
creators.forEach(function (owner) { | ||
promises.push(storage.getProjects({user: owner})); |
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.
Make sure to write a test that catches this.. It still uses the guest account - it should be username..
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.
cr.p
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.
You're not passing the correct argument to getProjects. This should be caught by a test
Introduces the config option seedProjects.createAtStartup an array of projects to be created at startup.