Socket
Socket
Sign inDemoInstall

@devoxa/integresql-client

Package Overview
Dependencies
25
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @devoxa/integresql-client

IntegreSQL client for managing isolated PostgreSQL databases in integration tests


Version published
Weekly downloads
1.4K
decreased by-0.43%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

integresql-client

IntegreSQL client for managing isolated PostgreSQL databases in integration tests.

Package Version Build Status Code Coverage

InstallationUsageContributorsLicense


Installation

yarn add --dev @devoxa/integresql-client

To install IntegreSQL, please follow their installation instructions.

Usage

Full example

For a full usage example, have a look the integration tests.

Step-by-step guide

  1. Initialize the IntegreSQL client
import { IntegreSQLClient } from '@devoxa/integresql-client'

const integreSQL = new IntegreSQLClient({ url: 'http://localhost:5000' })
// options.url: The URL of the IntegreSQL instance
  1. (Once per test runner process) Get a hash of the migrations & fixtures
// The hash can be generated in any way that fits your business logic, the included
// helper creates a SHA1 hash of the file content of all files matching the glob patterns.
const hash = await integreSQL.hashFiles(['./migrations/**/*', './fixtures/**/*'])
  1. (Once per test runner process) Initialize the template database
await integreSQL.initializeTemplate(hash, async (databaseConfig) => {
  await migrateTemplateDatabase(databaseConfig)
  await seedTemplateDatabase(databaseConfig)
  await disconnectFromDatabase(databaseConfig)
})
  1. (Before each test) Get a isolated test database
const databaseConfig = await integreSQL.getTestDatabase(hash)

Helpers

  • integreSQL.databaseConfigToConnectionUrl(databaseConfig)

API requests

You can directly send requests to the IntegreSQL instance via the included API client, or optionally instantiate a new IntegreSQLApiClient yourself.

await integreSQL.api.reuseTestDatabase(hash, id)

const api = new IntegreSQLApiClient({ url: 'http://localhost:5000' })
await api.reuseTestDatabase(hash, id)

Contributors

Thanks goes to these wonderful people (emoji key):


David Reeß

💻 📖 ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT

FAQs

Last updated on 29 Jul 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc