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

delete objects after test suite #146

Open
kedarnag138 opened this issue Jan 10, 2019 · 3 comments
Open

delete objects after test suite #146

kedarnag138 opened this issue Jan 10, 2019 · 3 comments

Comments

@kedarnag138
Copy link

kedarnag138 commented Jan 10, 2019

I'm using Dynamoose with factory-girl. In one of my test cases, I'm using the following

factory.createMany('xxxxxxx', 10).then((xxxxx) => {});

which is creating 10 records in my test db, however, what I'm trying to do is, I would like to delete those 10 records after the test suite is done from my local dynamoDB.

I did look at this link https://github.com/aexmachina/factory-girl#objectadapter, but there is no support for DynamoDB. Any suggestions on this?

@tomaszgiba
Copy link

Have you tried this? Factory#cleanUp
ex.

factory.createMany('xxxxxxx', 10).then((xxxxx) => {})
factory.cleanUp()

@lhendre
Copy link

lhendre commented Aug 1, 2019

I have tried that and it doesn't work?

@tomaszgiba
Copy link

I read that:
(https://github.com/aexmachina/factory-girl#factorycleanup)
cleanUp() calls destroy() method of an adapter:

  cleanUp() {
    const createdArray = [];
    for (const c of this.created) {
      createdArray.push(c);
    }
    const promise = createdArray.reduce(
      (prev, [adapter, model]) =>
        prev.then(() => adapter.destroy(model, model.constructor)),
      Promise.resolve()
    );
    this.created.clear();
    this.resetSeq();
    return promise;
  }

Briefly looking at Dynamoose's docs I can't see them having destroy() method at all: https://dynamoosejs.com/api/model/

Maybe that's the case.

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

3 participants