Skip to content
This repository has been archived by the owner on Jul 31, 2018. It is now read-only.

Auto-generation fixtures #2

Merged
merged 8 commits into from
Sep 20, 2015
Merged

Conversation

m4dz
Copy link
Contributor

@m4dz m4dz commented Aug 14, 2015

This PR allow defining fixtures as a model for Mockaroo service and then auto-generate and import fixtures on the fly. It adds two new floags to the CLI:

  • -g to enable the auto-generation service
  • -n to specify the number of records wanted

Note that it need an API key (freely available) available in the MOCKAROO_API_KEY env variable.

@frankrousseau
Copy link
Contributor

@jsilvestre Can I merge this PR?

.catch (err) ->
if err instanceof Mockaroo.errors.InvalidApiKeyError
err = 'invalid api key'
else if err instanceof Mockaroo.errors.UsageLimitExceededError
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that this line is less than 80 chars wide?

@m4dz
Copy link
Contributor Author

m4dz commented Aug 17, 2015

Ok, so tests are passing locally on a cozy base instance, and fail when passing on a freshly resetted db (w/ cozy-dev db:reset). I suppose that Travis fails for the same reasons but I can't find where's the problem (and my knowledge about the DS and Couch are a limit for me at this point). @poupotte, @jsilvestre, @aenario, any thoughs ?

@frankrousseau
Copy link
Contributor

Why did you rename tests in test? It's tests in every Cozy module.

@m4dz
Copy link
Contributor Author

m4dz commented Aug 19, 2015

I renamed it to test because it's a convention across all testing tools that the tests folder is named test. After discussing about it with @jsilvestre and debate about it's relevance, we admit it's a mistake and we choose to rename it to test, and piecemeal change the folder name to test in cozy apps 😀.

@aenario
Copy link
Contributor

aenario commented Aug 19, 2015

Mockaroo use babel, babel use core-js, core-js break chai zloirock/core-js#89

@m4dz
Copy link
Contributor Author

m4dz commented Aug 19, 2015

@aenario I don't see what you mean… broken tests on a resetted cozy db instance aren't due to the mockaroo addition : they'll break on the master branch too 😞. I haven't any issue running the auto-generation fixtures.

@frankrousseau
Copy link
Contributor

Ok, test is ugly. But if it's a standard... (sad)

About your bug @m4dz it's probably due to requests that are not declared (if the bug occurs only on empty database).

@m4dz
Copy link
Contributor Author

m4dz commented Aug 19, 2015

Ok, test is ugly. But if it's a standard... (sad)

I agree, I'm totally convinced by the theory of the "s" defective key 😆.

it's probably due to requests that are not declared

Yep. I'll try to fix it today.

@m4dz
Copy link
Contributor Author

m4dz commented Aug 19, 2015

Ok, so:

  1. tests fail locally on master branch only if they're applied on another db than cozy (some tests assume the tested couch db is the cozy one). My first mistake.
  2. tests are performed on the main.js file (not the coffee version) when this one is present, so I had som inconsistencies across same tests set because it wasn't compiled each time. Second mistake.
  3. @aenario, you're true, and I don't firstly understand what you mean. Core-js breaks Number prototype constructor and then chai assetions base on numbers fail (miserably). Third mistake.

So, now we have a culprit, i'll fix the assertions 😑 to bypass the issue…

@m4dz
Copy link
Contributor Author

m4dz commented Aug 19, 2015

As well as the issue is fixed in the core-js 1.0.0 branch, I've just submitted a patch to Mockaroo to update their deps as well : mockaroo/mockaroo-node#1.

@clochix
Copy link

clochix commented Sep 17, 2015

So, what's the status of this PR ? @m4dz, @jsilvestre ?

@m4dz
Copy link
Contributor Author

m4dz commented Sep 18, 2015

The code is fully functional, but the tests always fail due to the bug mentioned by @aenario, and the PR on Mockaroo is still alive.

I suggest we could merge this one (even with the tests failing) as we use it intensively (eg on Contacts for now), and I will up my PR on Mockaroo to fix the bug :)

frankrousseau pushed a commit that referenced this pull request Sep 20, 2015
@frankrousseau frankrousseau merged commit f684091 into cozy:master Sep 20, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants