Skip to content

Commit 6fe748b

Browse files
Cassandra
1 parent 876d962 commit 6fe748b

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

docs/modules/arangodb.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ npm install @testcontainers/arangodb --save-dev
88

99
## Example
1010

11-
This example uses the [arangojs](https://www.npmjs.com/package/arangojs/v/6.0.0-alpha.0) library:
11+
This example uses the following libraries:
1212

13-
```bash
14-
npm install arangojs
15-
```
13+
- [arangojs](https://www.npmjs.com/package/arangojs/v/6.0.0-alpha.0)
14+
15+
npm install arangojs
1616

1717
---
1818

docs/modules/cassandra.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# Cassandra Module
2-
3-
[Cassandra](https://cassandra.apache.org/_/index.html) is a free and open source, distributed NoSQL database management system. It is designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure.
4-
5-
1+
# Cassandra
62

73
## Install
84

@@ -12,18 +8,30 @@ npm install @testcontainers/cassandra --save-dev
128

139
## Examples
1410

15-
<!--codeinclude-->
16-
[Connect:](../../packages/modules/cassandra/src/cassandra-container.test.ts) inside_block:connectWithDefaultCredentials
17-
<!--/codeinclude-->
11+
These examples use the following libraries:
12+
13+
- [cassandra-driver](https://www.npmjs.com/package/cassandra-driver)
14+
15+
npm install cassandra-driver
16+
17+
---
18+
19+
Choose an image from [Docker Hub](https://hub.docker.com/_/cassandra) and substitute `IMAGE`.
20+
21+
### Execute a query
1822

1923
<!--codeinclude-->
20-
[Connect with custom credentials:](../../packages/modules/cassandra/src/cassandra-container.test.ts) inside_block:connectWithCustomCredentials
24+
[](../../packages/modules/cassandra/src/cassandra-container.test.ts) inside_block:connectWithDefaultCredentials
2125
<!--/codeinclude-->
2226

27+
### Custom credentials
28+
2329
<!--codeinclude-->
24-
[With custom datacenter / rack](../../packages/modules/cassandra/src/cassandra-container.test.ts) inside_block:customDataCenterAndRack
30+
[](../../packages/modules/cassandra/src/cassandra-container.test.ts) inside_block:connectWithCustomCredentials
2531
<!--/codeinclude-->
2632

33+
### Custom datacenter / rack
34+
2735
<!--codeinclude-->
28-
[Insert & fetch data:](../../packages/modules/cassandra/src/cassandra-container.test.ts) inside_block:createAndFetchData
36+
[](../../packages/modules/cassandra/src/cassandra-container.test.ts) inside_block:customDataCenterAndRack
2937
<!--/codeinclude-->

packages/modules/cassandra/src/cassandra-container.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,26 @@ import { CassandraContainer } from "./cassandra-container";
66
const IMAGE = getImage(__dirname);
77

88
describe.sequential("Cassandra", { timeout: 240_000 }, () => {
9-
// connectWithDefaultCredentials {
109
it("should connect and execute a query with default credentials", async () => {
10+
// connectWithDefaultCredentials {
1111
await using container = await new CassandraContainer(IMAGE).start();
1212

1313
const client = new Client({
1414
contactPoints: [container.getContactPoint()],
1515
localDataCenter: container.getDatacenter(),
1616
keyspace: "system",
1717
});
18-
1918
await client.connect();
2019

2120
const result = await client.execute("SELECT release_version FROM system.local");
2221
expect(result.rows[0].release_version).toBe(ImageName.fromString(IMAGE).tag);
2322

2423
await client.shutdown();
24+
// }
2525
});
26-
// }
2726

28-
// connectWithCustomCredentials {
2927
it("should connect with custom username and password", async () => {
28+
// connectWithCustomCredentials {
3029
const username = "testUser";
3130
const password = "testPassword";
3231

@@ -38,6 +37,7 @@ describe.sequential("Cassandra", { timeout: 240_000 }, () => {
3837
credentials: { username, password },
3938
keyspace: "system",
4039
});
40+
// }
4141

4242
await client.connect();
4343

@@ -46,12 +46,12 @@ describe.sequential("Cassandra", { timeout: 240_000 }, () => {
4646

4747
await client.shutdown();
4848
});
49-
// }
5049

51-
// customDataCenterAndRack {
5250
it("should set datacenter and rack", async () => {
51+
// customDataCenterAndRack {
5352
const customDataCenter = "customDC";
5453
const customRack = "customRack";
54+
5555
await using container = await new CassandraContainer(IMAGE)
5656
.withDatacenter(customDataCenter)
5757
.withRack(customRack)
@@ -61,15 +61,15 @@ describe.sequential("Cassandra", { timeout: 240_000 }, () => {
6161
contactPoints: [container.getContactPoint()],
6262
localDataCenter: container.getDatacenter(),
6363
});
64-
6564
await client.connect();
65+
6666
const result = await client.execute("SELECT data_center, rack FROM system.local");
6767
expect(result.rows[0].data_center).toBe(customDataCenter);
6868
expect(result.rows[0].rack).toBe(customRack);
6969

7070
await client.shutdown();
71+
// }
7172
});
72-
// }
7373

7474
// createAndFetchData {
7575
it("should create keyspace, a table, insert data, and retrieve it", async () => {

0 commit comments

Comments
 (0)