0.3.0 • Published 5 years ago

documentclient-mock v0.3.0

Weekly downloads
73
License
MIT
Repository
-
Last release
5 years ago

documentclient-mock

Build Status

documentclient-mock is a mock implementation of AWS.DynamoDB.DocumentClient. While it is a work in progress, it has many of the main features of DocumentClient implemented and operates all in memory. It even includes expression evaluators for condition expressions and update expressions. The main purpose is to allow you to create databases in memory to test business logic against them.

Installation

npm install --save-dev documentclient-mock

Usage

const documentClient = require('documentclient-mock');
const client = documentClient({
  defns: {
    TestTable: {
      keySchema: [
        {
          keyType: 'HASH',
          attributeName: 'partitionKey'
        }
      ],
      attributeDefinitions: [
        {
          attributeName: 'partitionKey',
          attributeType: 'S'
        }
      ]
    }
  },
  tables: {
    TestTable: {
      test: {
        partitionKey: 'test'
      }
    }
  }
});
client.get({
  TableName: 'TestTable',
  Key: { partitionKey: 'test' }
}).promise().then(doc => {
  console.log(doc);
});

documentClient has three options in its parameter:

  • defns - a hash of table name to table definition
  • tables - a hash of table name to partitions
  • fn - a function wrapper for client methods. example jest.fn

Contributing

Contributions are welcomed as not all of the functionality is implemented yet. There is some low hanging fruit with TODOs sprinkled throughout the code. If a new feature is implemented or a change is made please add a corresponding test. Also please ensure all lint checks and tests pass.

Versioning

All patch versions are computed from previous tags on the master branch. To bump a version please increment the major or minor version in package.json before making the pull request.

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.27

5 years ago

0.1.26

5 years ago

0.1.25

5 years ago

0.1.24

5 years ago

0.1.23

5 years ago

0.1.22

5 years ago

0.1.21

5 years ago

0.1.20

5 years ago

0.1.19

5 years ago

0.1.18

5 years ago

0.1.17

5 years ago

0.1.16

5 years ago

0.1.0

5 years ago