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

Various tests improvements #18

Merged
merged 23 commits into from
Dec 10, 2015
Merged

Various tests improvements #18

merged 23 commits into from
Dec 10, 2015

Conversation

paolochiodi
Copy link
Contributor

This PR includes:

This PR does not include:

  • updates to the README
  • version bump
  • wrapped errors as discussed in Type of error returned by stores #14 (I'm working on an additional PR to bring that, but would like to get this merged first)

Notes:

  • instead of relying on test.sh to install seneca I added it to devDependencies. I'm not 100% sure it's the right place
  • this will require an update to how tests are run on the stores, since it now requires a "senecaMerge" option. That should be an instance of seneca with the store configured with the merge option set to false
  • tested with seneca from 0.5 to 0.7, node 0.10, 0.12, 4, 4.1
  • mem-store included with seneca fails some of the tests

@paolochiodi
Copy link
Contributor Author

Please note that travis checks fail because the men-store used for the tests doesn't fully follow standards

@@ -1,4 +1,6 @@
language: node_js
node_js:
- "0.11"
- "4.1"
Copy link
Member

Choose a reason for hiding this comment

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

Can use "4" instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you think I should add "4" and also leave 4.1 and 4.0 since 4.2 has been released?

Copy link
Member

Choose a reason for hiding this comment

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

I would make it "4" to test against the current 4.x release.

@mcdonnelldean
Copy link

@paolochiodi Can you look at the failing tests? There are a couple of them.

@@ -4,7 +4,7 @@
"description": "Standard test cases for seneca stores",
"main": "store-test.js",
"scripts": {
"test": "./test.sh"
"test": "lab test/*.test.js -r console -v -L"

Choose a reason for hiding this comment

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

You might want to set the timeout here to 3000 we have found travis can be slow at times and cause tests to fail due to overrun. 3000 seems to be the sweet spot.

@paolochiodi
Copy link
Contributor Author

@mcdonnelldean tests on this repot aren't real tests
They actually use the tests in this module to test the mem-store built in seneca (which I think is considered a "reference implementation".

I've introduced some new test to better cover the data entities specification, and some them are failing because even men-store doesn't fully and correctly implement that. In order to have all tests green we should amend the mem-store

@mcdonnelldean
Copy link

@paolochiodi super, as discussed let's fix up mem store while we wait for @rjrodger to review.

@paolochiodi paolochiodi mentioned this pull request Nov 3, 2015
@geek
Copy link
Member

geek commented Nov 3, 2015

@paolochiodi this change looks good... I would like to get the changes to mem-store in first so that we can have all green tests. I went ahead and merged in #22, so you will need to pull down those changes and merge :/

@paolochiodi
Copy link
Contributor Author

I've rebased to incorporate latest changes in master branch.
I've also updated seneca and seneca-men-store to make all tests pass (relevant PR here senecajs/seneca#217 and here senecajs/seneca-mem-store#36)

Releasing these will require some coordination and some work on package.json to highlight that these spec changes:

  1. break existing spec and stores
  2. require latest versions of seneca (the ones including follow new store specs seneca#217)

@paolochiodi
Copy link
Contributor Author

Rebased to bring this up-to-date with master

scratch.foo2.p2 = 'v2'
it('should allow to not merge during update with merge$: false', function (done) {
var foo = si.make('foo')
foo.id = 'to-be-updated'
Copy link
Contributor

Choose a reason for hiding this comment

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

@paolochiodi I think is better not to define id values in these tests. Some DB engines have rules about ids - like MongoDB that uses an ObjectId. So in order to use these tests as a standard maybe we should not have id values defined in these tests.

The id can be retrieved from callback of the save action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess this also relates to senecajs-labs/seneca-shard-store#11
On a general note I'm ok to rewrite tests in a way that createEntities will store auto-generated ids for later uses (i.e.: when we want to update the entities, like this case).

I begin to feel that at this point may be better to remove the possibility to specify the id on create from the specs, if many of the DB engines can't support them. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am the supporter of the idea that we should have something like this:

  • define a set of functions that all stores will try to follow - the "standard" store functions that we have now
  • support in the stores as many as possible "standard" functions offered by the DB engines. Here is also this function of allowing to specify the id or the entity to be saved if that is supported.
  • clearly specify in the documentation when a certain store do not have support for a "standard" function.

So, from my point of view, if Riak do not support list$ is not a problem, but we should clearly specify this in its documentation. The developers that will use that store probably know already this thing.

I also think that the benefit of having a functional store with all necessary tools offered by a specific DB engine is greater than limiting all stores to the smallest set of common functions offered by all DB engines.

Shard-store can also have a list of specific functions that should not be used by developers if they want to have it run correctly - this should not limit the actual functions implemented in the used stores.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree on the idea of having a basic set of standard functions, but I think all the stores must support that minimal set.

The entity framework is quite minimal and doesn't add much to the db driver beside a common api, I don't see the point of having a store for a db that can't support that api: sometimes may be better to directly go with the driver or a different type of abstraction (e.g: https://github.com/AdrianRossouw/seneca-knex-store)

Maybe @rjrodger and @geek can weight in their opinion?

Also let me know how to proceed with this PR, if I need to split the tests into different "levels" of support

@geek geek self-assigned this Nov 24, 2015
paolochiodi added a commit that referenced this pull request Dec 10, 2015
@paolochiodi paolochiodi merged commit eaf0f48 into senecajs:master Dec 10, 2015
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

Successfully merging this pull request may close these issues.

4 participants