testcontainers-cockroach
v0.0.2
Published
Cockroach module for Testcontainers
Downloads
13
Maintainers
Readme
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