Implementation of testcontainers-node for cockroach database.
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
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')
This project is licensed under the MIT License