/seneca-store-test

Standard test cases for seneca stores.

Primary LanguageJavaScriptMIT LicenseMIT

Seneca

A Seneca.js plugin

seneca-store-test

npm version Build Status Build Dependency Status Coveralls Maintainability DeepScan grade

Description

This module provides a standard set of tests for Seneca data stores.

It is used to verify that a store meets the minimum requirements needed for the Seneca data message patterns. See the Seneca Data Entities article for more information.

This module is included as a development dependency by Seneca data store plugins. For a simple example, see the seneca-mem-store plugin test cases.

If you're using this module, and need help, you can:

seneca-store-test's source can be read in an annotated fashion by,

  • running npm run annotate

The annotated source can be found locally at ./doc/store-test.html.

Install

npm install seneca-store-test

Contributing

The Senecajs org encourage open participation. If you feel you can help in any way, be it with documentation, examples, extra testing, or new features please get in touch.

Before you test

Passing the test for race conditions

Chances are, in order to pass the test for race conditions, you need to create
a unique index on the users.email column/field, - whether you are testing
a plugin meant for a SQL or a NoSQL database/store.

That's due to the way how upserts are normally implemented in databases.

For example, in case of MongoDb, in order for the database to be able to avert
race conditions, a field you upsert on must have a unique index created on it.
Without the index, your upserts will not be atomic, and as a result your plugin
will fail the race condition tests.

It is a case of a leaky abstraction that test suites of client store plugins
must "know" what collection and what field is being used in a race condition
test in seneca-store-test. We may want to come up with a better alternative
in the future.

Test

npm run test

License

Copyright (c) 2013-2018, Richard Rodger and other contributors. Licensed under MIT.