Skip to content

zloom/testcontainers-cockroach

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version npm downloads gitHub license

Cockroach testcontainer module

Implementation of testcontainers-node for cockroach database.

Limitations

This implementation uses single node insecure instance of cockroach, in this mode you cannot set password for db. With persistent database storage cockroach required volume attached, so cockroach warns at start about data folder. There is memory storage type can be configured .withMemoryStorage(), additionaly you can tune db at start for better performance as descripted here

Usage

const container = await new CockroachContainer();
container.withDatabase('testsdb');

const startedContainer = await container.start();
const connectionString = startedContainer.getConnectionUri();

const client = new Client(connectionString);
client.connect();

await client.query('CREATE TABLE accounts (id UUID PRIMARY KEY, balance INT8)');
await client.query(`INSERT INTO accounts (id, balance) VALUES ($1, 1000), ($2, 250), ($3, 0)`, [v4(), v4(), v4()]);
const accountsResult = await client.query('SELECT id, balance FROM accounts ORDER BY balance')

License

This project is licensed under the MIT License

About

Cockroach database module for Testcontainers

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published