--- /dev/null
+/* eslint-disable class-methods-use-this */
+'use strict';
+
+const sinon = require('sinon'); // eslint-disable-line node/no-unpublished-require
+
+class StubDatabase {
+ constructor() {
+ this._implementation.forEach((fn) => {
+ if (!(fn in this)) {
+ this[fn] = async () => { /* */ }; // eslint-disable-line security/detect-object-injection
+ }
+ });
+ }
+
+ get _implementation() {
+ return [
+ ...this._spyFns,
+ ...this._stubFns,
+ ];
+ }
+
+ get _spyFns() {
+ return [
+ 'context',
+ 'transaction',
+ ];
+ }
+
+ get _stubFns() {
+ return [
+ 'initialize',
+ 'healthCheck',
+ ];
+ }
+
+ _reset() {
+ this._spyFns.forEach((fn) => {
+ sinon.spy(this, fn);
+ });
+ this._stubFns.forEach((fn) => {
+ sinon.stub(this, fn);
+ });
+ }
+
+ async context(fn) {
+ await fn({});
+ }
+
+ async transaction(dbCtx, fn) {
+ await fn(dbCtx);
+ }
+
+}
+
+module.exports = StubDatabase;