Skip to content

Instantly share code, notes, and snippets.

@henryoswald
Created May 26, 2015 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henryoswald/0ca8d12b594be9d1b745 to your computer and use it in GitHub Desktop.
Save henryoswald/0ca8d12b594be9d1b745 to your computer and use it in GitHub Desktop.
create random users with projects and linking
UserCreator = require("./app/js/Features/User/UserCreator")
ProjectCreationHandler = require("./app/js/Features/Project/ProjectCreationHandler")
CollaboratorsHandler = require("./app/js/Features/Collaborators/CollaboratorsHandler")
uuid = require('node-uuid')
async = require("async")
_ = require("underscore")
require("./app/js/Features/Email/EmailSender").sendEmail= (opts, cb)->
cb()
randomString = ->
uuid.v4().split("-")[0]
createdUsers = []
projects = []
createUsers = _.map [0..50], ->
return (cb)->
UserCreator.createNewUser {email:"#{randomString()}@gmail.com"}, (err, user)->
createdUsers.push(user)
cb()
createProjects = _.map [0..100], ->
return (cb)->
user = _.sample(createdUsers)
ProjectCreationHandler.createBlankProject user._id, randomString(), (err, project)->
projects.push(project)
cb()
createConnections = _.map [0..100], ->
return (cb)->
user = _.sample(createdUsers)
project = _.sample(projects)
console.log user.email, project._id
CollaboratorsHandler.addUserToProject project._id, user.email, "readAndWrite", cb
async.parallelLimit createUsers, 10, (err)->
async.parallelLimit createProjects, 10, (err)->
async.parallelLimit createConnections, 20, (err)->
console.log createdUsers[0]._id
console.log createdUsers[1]._id
process.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment