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
- ff6347 hash@ff6347.email
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):
Fabian Morón Zirfas |
Lucas Vogel |
This project follows the all-contributors specification. Contributions of any kind welcome!
Credits
|
A project by:
|
Supported by:
|