Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MockDB

Provides a simple API for starting and stopping a single database container, using Node's child_process API to pass commands to the docker CLI. As such, this requires docker to be running on the machine, and requires the parent of the node process to have permission to interact with it.

Hierarchy

  • MockDB

Index

Constructors

constructor

Properties

Private container

container: ChildProcess

A reference to the running child_process attached to the container

Private databaseName

databaseName: string

A name for the database inside the container

init

init: function

expose a public init function bound to this

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

Private name

name: string

A name for identifying the container

Private password

password: string

The password for the user account

Private port

port: number

The external port which will forward to 5432

Private state

Whether the container is running or dead

stop

stop: function

expose a public stop function bound to this

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

Private user

user: string

The user account who will own the database

Accessors

connectionEnv

  • get connectionEnv(): object
  • Outputs the basic connection parameters needed to connect to the database from TypeORM. Formatted to be passed into the contstructor of the ConfigService

    Returns object

    • [key: string]: string

Methods

Private _init

  • _init(): Promise<void>
  • Spawns a child process attached to the call to 'container run'.

    Returns Promise<void>

    resolves once the container is running, or rejects if there is an error.

Private _stop

  • _stop(): Promise<void>
  • stops the running container 'docker container stop'.

    Returns Promise<void>

    resolves once the container is stopped, or rejects if there is an error stopping it

Generated using TypeDoc