1.0.4 • Published 2 years ago

@technologiestiftung/stadtpuls-test-utils v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

npm.io

Version npm.io Documentation Maintenance License: MIT

Welcome to stadtpuls-test-utils

This repo contains shared test utilities for the stadtpuls project.

Prerequisites

  • node >=14

Install

npm i @technologiestiftung/stadtpuls-test-utils

Usage

Commonjs

//@ts-check
const {
  closePool,
  openPool,
  getClient,
  execQuery,
} = require("@technologiestiftung/stadtpuls-test-utils");

async function main() {
  await openPool("postgres://postgres:postgres@localhost:5432/postgres");
  const client = await getClient();
  await client.query(
    "CREATE TABLE IF NOT EXISTS test (id serial PRIMARY KEY, name varchar(255))"
  );
  await client.query("INSERT INTO test (name) VALUES ($1)", ["foo"]);
  const result = await client.query("SELECT * FROM test", []);
  // @ts-ignore
  console.log(result.rows);
  await closePool();
}
main().catch(console.error);

Typescript & ESM

import {
  closePool,
  openPool,
  getClient,
  execQuery,
} from "@technologiestiftung/stadtpuls-test-utils";

async function main() {
  await openPool("postgres://postgres:postgres@localhost:5432/postgres");
  const client = await getClient();
  await client.query(
    "CREATE TABLE IF NOT EXISTS test (id serial PRIMARY KEY, name varchar(255))"
  );
  await client.query("INSERT INTO test (name) VALUES ($1)", ["foo"]);
  const result = await client.query("SELECT * FROM test", []);
  // @ts-ignore
  console.log(result.rows);
  await closePool();
}
main().catch(console.error);

Run tests

npm test

Maintainers

License

Copyright © 2022 Technologiestiftung Berlin & Fabian Morón Zirfas. This project is MIT licensed.

Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.

Contributors

Thanks goes to these wonderful people (emoji key):

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

Credits