Skip to content

Commit 7dc04c2

Browse files
committed
fix: lint about using we and more
1 parent 272bb8b commit 7dc04c2

File tree

4 files changed

+63
-71
lines changed

4 files changed

+63
-71
lines changed

content/manuals/testcontainers/benefits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ automatically after the test execution is complete by using the Ryuk sidecar con
3838
While starting the required containers, Testcontainers attaches a set of labels to the
3939
created resources (containers, volumes, networks etc) and Ryuk automatically performs
4040
resource clean up by matching those labels.
41-
This works reliably even when the test process exits abnormally (e.g. sending a SIGKILL).
41+
This works reliably even when the test process exits abnormally (for example sending a SIGKILL).

content/manuals/testcontainers/getting-started/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ It is possible to configure Testcontainers to work for other Docker setups, such
3131
However, these are not actively tested in the main development workflow, so not all Testcontainers features might be available
3232
and additional manual configuration might be necessary.
3333

34-
If you have further questions about configuration details for your setup or whether it supports running Testcontainers-based tests,
35-
please contact the Testcontainers team and other users from the Testcontainers community on [Slack](https://slack.testcontainers.org/).
34+
If you have further questions about configuration details for your setup or whether it supports running Testcontainers-based tests,
35+
contact the Testcontainers team and other users from the Testcontainers community on [Slack](https://slack.testcontainers.org/).

content/manuals/testcontainers/getting-started/go.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ From the [Go Release Policy](https://go.dev/doc/devel/release#policy):
2222

2323
> Each major Go release is supported until there are two newer major releases. For example, Go 1.5 was supported until the Go 1.7 release, and Go 1.6 was supported until the Go 1.8 release. We fix critical problems, including critical security problems, in supported releases as needed by issuing minor revisions (for example, Go 1.6.1, Go 1.6.2, and so on).
2424
25-
_Testcontainers for Go_ is tested against those two latest Go releases, therefore we recommend using any of them.
25+
_Testcontainers for Go_ is tested against those two latest Go releases, therefore it's recommended to use any of them.
2626

27-
## Step 1:Install _Testcontainers for Go_
27+
## Step 1: Install _Testcontainers for Go_
2828

2929
_Testcontainers for Go_ uses [go mod](https://blog.golang.org/using-go-modules) and you can get it installed via:
3030

@@ -66,28 +66,26 @@ look.
6666

6767
* `Image` is the Docker image the container starts from.
6868
* `ExposedPorts` lists the ports to be exposed from the container.
69-
* `WaitingFor` is a field you can use to validate when a container is ready. It
70-
is important to get this set because it helps to know when the container is
71-
ready to receive any traffic. In this case, we check for the logs we know come
72-
from Redis, telling us that it is ready to accept requests.
69+
* `WaitingFor` is a field you can use to validate when a container is ready.
70+
It is important to get this set because it helps to know when the container is
71+
ready to receive any traffic. In this case, the project checks for the logs that come from Redis, mentioning that it is ready to accept requests.
7372

7473
When you use `ExposedPorts` you have to imagine yourself using `docker run -p
75-
<port>`. When you do so, `dockerd` maps the selected `<port>` from inside the
74+
<port>`. When you do so, `dockerd` maps the selected `<port>` from inside the
7675
container to a random one available on your host.
7776

78-
In the previous example, we expose `6379` for `tcp` traffic to the outside. This
77+
In the previous example, the `6379/tcp` port is exposed to the outside. This
7978
allows Redis to be reachable from your code that runs outside the container, but
80-
it also makes parallelization possible because if you add `t.Parallel` to your
81-
tests, and each of them starts a Redis container each of them will be exposed on a
82-
different random port.
79+
it also makes parallel execution possible: if you add `t.Parallel` to your
80+
tests, and each of them starts a Redis container, then each of them will be
81+
exposed on a different random port.
8382

84-
`testcontainers.GenericContainer` creates the container. In this example we are
85-
using `Started: true`. It means that the container function will wait for the
83+
`testcontainers.GenericContainer` creates the container. This example uses `Started: true`. It means that the container function will wait for the
8684
container to be up and running. If you set the `Start` value to `false` it won't
8785
start, leaving to you the decision about when to start it.
8886

8987
All the containers must be removed at some point, otherwise they will run until
90-
the host is overloaded. One of the ways we have to clean up is by deferring the
88+
the host is overloaded. You can do the clean up by deferring the
9189
terminated function: `defer testcontainers.TerminateContainer(redisC)` which
9290
automatically handles nil container so is safe to use even in the error case.
9391

@@ -96,11 +94,11 @@ automatically handles nil container so is safe to use even in the error case.
9694
> Look at [features/garbage_collector](https://golang.testcontainers.org/features/garbage_collector/) to know another
9795
> way to clean up resources.
9896
99-
## Step 3: Make your code talk to the container
97+
## Step 3: Talking to the container
10098

10199
This is just an example, but usually Go applications that rely on Redis are
102100
using the [redis-go](https://github.com/go-redis/redis) client. This code gets
103-
the endpoint from the container we just started, and it configures the client.
101+
the endpoint from the container that was started before, and it configures the client.
104102

105103
```go
106104
endpoint, err := redisC.Endpoint(ctx, "")
@@ -115,7 +113,7 @@ client := redis.NewClient(&redis.Options{
115113
_ = client
116114
```
117115

118-
We expose only one port, so the `Endpoint` does not need a second argument set.
116+
The container exposed only one port, so the `Endpoint` does not need a second argument set.
119117

120118
> [!TIP]
121119
>
@@ -130,4 +128,4 @@ You can run the test via `go test ./...`
130128

131129
## Step 5: Want to go deeper with Redis?
132130

133-
You can find a more elaborated Redis example in our examples section. Please check it out [here](https://golang.testcontainers.org/modules/redis/).
131+
You can find a more elaborated Redis example in the [Redis module docs](https://golang.testcontainers.org/modules/redis/).

content/manuals/testcontainers/getting-started/java.md

Lines changed: 44 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ weight: 20
1616

1717
It's easy to add Testcontainers to your project - let's walk through a quick example to see how.
1818

19-
Let's imagine we have a simple program that has a dependency on Redis, and we want to add some tests for it.
20-
In our imaginary program, there is a `RedisBackedCache` class which stores data in Redis.
19+
Let's imagine you have a simple program that has a dependency on Redis, and you want to add some tests for it.
20+
In your imaginary program, there is a `RedisBackedCache` class which stores data in Redis.
2121

2222
You can see an example test that could have been written for it (without using Testcontainers):
2323

@@ -43,8 +43,8 @@ public class RedisBackedCacheIntTestStep0 {
4343
```
4444

4545
Notice that the existing test has a problem - it's relying on a local installation of Redis, which is a red flag for test reliability.
46-
This may work if we were sure that every developer and CI machine had Redis installed, but would fail otherwise.
47-
We might also have problems if we attempted to run tests in parallel, such as state bleeding between tests, or port clashes.
46+
This may work if you were sure that every developer and CI machine had Redis installed, but would fail otherwise.
47+
You might also have problems if you attempted to run tests in parallel, such as state bleeding between tests, or port clashes.
4848

4949
Let's start from here, and see how to improve the test with Testcontainers:
5050

@@ -74,9 +74,9 @@ testImplementation "org.testcontainers:testcontainers:{{latest_version}}"
7474
{{< /tab >}}
7575
{{< /tabs >}}
7676

77-
### Step 2: Get Testcontainers to run a Redis container during our tests
77+
### Step 2: Run a Redis container in the tests
7878

79-
Simply add the following to the body of our test class:
79+
Simply add the following to the body of your test class:
8080

8181
```java
8282
@Rule
@@ -85,22 +85,22 @@ public GenericContainer redis = new GenericContainer(DockerImageName.parse("redi
8585
```
8686

8787
The `@Rule` annotation tells JUnit to notify this field about various events in the test lifecycle.
88-
In this case, our rule object is a Testcontainers `GenericContainer`, configured to use a specific Redis image from Docker Hub, and configured to expose a port.
88+
In this case, the rule object is a Testcontainers `GenericContainer`, configured to use a specific Redis image from Docker Hub, and configured to expose a port.
8989

90-
If we run our test as-is, then regardless of the actual test outcome, we'll see logs showing us that Testcontainers:
90+
If you run your test as-is, then regardless of the actual test outcome, you'll see logs showing you that Testcontainers:
9191

92-
* was activated before our test method ran
93-
* discovered and quickly tested our local Docker setup
92+
* was activated before the test method ran
93+
* discovered and quickly tested the local Docker setup
9494
* pulled the image if necessary
9595
* started a new container and waited for it to be ready
9696
* shut down and deleted the container after the test
9797

98-
### Step 3: Make sure our code can talk to the container
98+
### Step 3: Make sure the code can talk to the container
9999

100-
Before Testcontainers, we might have hardcoded an address like `localhost:6379` into our tests.
100+
Before Testcontainers, you might have hard-coded an address like `localhost:6379` into your tests.
101101

102102
Testcontainers uses *randomized ports* for each container it starts, but makes it easy to obtain the actual port at runtime.
103-
We can do this in our test `setUp` method, to set up our component under test:
103+
You can do this in your test `setUp` method, to set up your component under test:
104104

105105
```java
106106
String address = redis.getHost();
@@ -112,16 +112,14 @@ underTest = new RedisBackedCache(address, port);
112112

113113
> [!TIP]
114114
>
115-
> Notice that we also ask Testcontainers for the container's actual address with `redis.getHost();`,
115+
> Notice that the previous code also asks Testcontainers for the container's actual address with `redis.getHost();`,
116116
> rather than hard-coding `localhost`. `localhost` may work in some environments but not others - for example it may
117117
> not work on your current or future CI environment. As such, **avoid hard-coding** the address, and use
118118
> `getHost()` instead.
119119
120120
### Step 4: Run the tests
121121

122-
That's it!
123-
124-
Let's look at our complete test class to see how little we had to add to get up and running with Testcontainers:
122+
Let's look at the complete test class to see how little you had to add to get up and running with Testcontainers:
125123

126124
```java
127125
public class RedisBackedCacheIntTest {
@@ -158,8 +156,8 @@ public class RedisBackedCacheIntTest {
158156

159157
It's easy to add Testcontainers to your project - let's walk through a quick example to see how.
160158

161-
Let's imagine we have a simple program that has a dependency on Redis, and we want to add some tests for it.
162-
In our imaginary program, there is a `RedisBackedCache` class which stores data in Redis.
159+
Let's imagine you have a simple program that has a dependency on Redis, and you want to add some tests for it.
160+
In your imaginary program, there is a `RedisBackedCache` class which stores data in Redis.
163161

164162
You can see an example test that could have been written for it (without using Testcontainers):
165163

@@ -185,8 +183,8 @@ public class RedisBackedCacheIntTestStep0 {
185183
```
186184

187185
Notice that the existing test has a problem - it's relying on a local installation of Redis, which is a red flag for test reliability.
188-
This may work if we were sure that every developer and CI machine had Redis installed, but would fail otherwise.
189-
We might also have problems if we attempted to run tests in parallel, such as state bleeding between tests, or port clashes.
186+
This may work if you were sure that every developer and CI machine had Redis installed, but would fail otherwise.
187+
You might also have problems if you attempted to run tests in parallel, such as state bleeding between tests, or port clashes.
190188

191189
Let's start from here, and see how to improve the test with Testcontainers:
192190

@@ -230,9 +228,9 @@ testImplementation "org.testcontainers:junit-jupiter:{{latest_version}}"
230228
{{< /tab >}}
231229
{{< /tabs >}}
232230

233-
### Step 2: Get Testcontainers to run a Redis container during our tests
231+
### Step 2: Get Testcontainers to run a Redis container during the tests
234232

235-
First, you'll need to annotate the test class with `@Testcontainers`. Furthermore, add the following to the body of our test class:
233+
First, you'll need to annotate the test class with `@Testcontainers`. Furthermore, add the following to the body of the test class:
236234

237235
```java
238236
@Container
@@ -241,22 +239,22 @@ public GenericContainer redis = new GenericContainer(DockerImageName.parse("redi
241239
```
242240

243241
The `@Container` annotation tells JUnit to notify this field about various events in the test lifecycle.
244-
In this case, our rule object is a Testcontainers `GenericContainer`, configured to use a specific Redis image from Docker Hub, and configured to expose a port.
242+
In this case, the rule object is a Testcontainers `GenericContainer`, configured to use a specific Redis image from Docker Hub, and configured to expose a port.
245243

246-
If we run our test as-is, then regardless of the actual test outcome, we'll see logs showing us that Testcontainers:
244+
If you run your test as-is, then regardless of the actual test outcome, you'll see logs showing you that Testcontainers:
247245

248-
* was activated before our test method ran
249-
* discovered and quickly tested our local Docker setup
246+
* was activated before the test method ran
247+
* discovered and quickly tested the local Docker setup
250248
* pulled the image if necessary
251249
* started a new container and waited for it to be ready
252250
* shut down and deleted the container after the test
253251

254-
### Step 3: Make sure our code can talk to the container
252+
### Step 3: Make sure the code can talk to the container
255253

256-
Before Testcontainers, we might have hardcoded an address like `localhost:6379` into our tests.
254+
Before Testcontainers, you might have hard-coded an address like `localhost:6379` into your tests.
257255

258256
Testcontainers uses *randomized ports* for each container it starts, but makes it easy to obtain the actual port at runtime.
259-
We can do this in our test `setUp` method, to set up our component under test:
257+
You can do this in your test `setUp` method, to set up your component under test:
260258

261259
```java
262260
String address = redis.getHost();
@@ -268,7 +266,7 @@ underTest = new RedisBackedCache(address, port);
268266

269267
> [!TIP]
270268
>
271-
> Notice that we also ask Testcontainers for the container's actual address with `redis.getHost();`,
269+
> Notice that the previous code also asks Testcontainers for the container's actual address with `redis.getHost();`,
272270
> rather than hard-coding `localhost`. `localhost` may work in some environments but not others - for example it may
273271
> not work on your current or future CI environment. As such, **avoid hard-coding** the address, and use
274272
> `getHost()` instead.
@@ -284,9 +282,7 @@ current environment. Set `disabledWithoutDocker` to `true`.
284282

285283
### Step 5: Run the tests
286284

287-
That's it!
288-
289-
Let's look at our complete test class to see how little we had to add to get up and running with Testcontainers:
285+
Let's look at the complete test class to see how little you had to add to get up and running with Testcontainers:
290286

291287
```java
292288
@Testcontainers
@@ -324,8 +320,8 @@ public class RedisBackedCacheIntTest {
324320

325321
It's easy to add Testcontainers to your project - let's walk through a quick example to see how.
326322

327-
Let's imagine we have a simple program that has a dependency on Redis, and we want to add some tests for it.
328-
In our imaginary program, there is a `RedisBackedCache` class which stores data in Redis.
323+
Let's imagine you have a simple program that has a dependency on Redis, and you want to add some tests for it.
324+
In your imaginary program, there is a `RedisBackedCache` class which stores data in Redis.
329325

330326
You can see an example test that could have been written for it (without using Testcontainers):
331327

@@ -352,8 +348,8 @@ class RedisBackedCacheIntTestStep0 extends Specification {
352348
```
353349

354350
Notice that the existing test has a problem - it's relying on a local installation of Redis, which is a red flag for test reliability.
355-
This may work if we were sure that every developer and CI machine had Redis installed, but would fail otherwise.
356-
We might also have problems if we attempted to run tests in parallel, such as state bleeding between tests, or port clashes.
351+
This may work if you were sure that every developer and CI machine had Redis installed, but would fail otherwise.
352+
You might also have problems if you attempted to run tests in parallel, such as state bleeding between tests, or port clashes.
357353

358354
Let's start from here, and see how to improve the test with Testcontainers:
359355

@@ -383,7 +379,7 @@ testImplementation "org.testcontainers:spock:{{latest_version}}"
383379
{{< /tab >}}
384380
{{< /tabs >}}
385381

386-
### Step 2: Get Testcontainers to run a Redis container during our tests
382+
### Step 2: Get Testcontainers to run a Redis container during the tests
387383

388384
Annotate the Spock specification class with the Testcontainers extension:
389385

@@ -392,7 +388,7 @@ Annotate the Spock specification class with the Testcontainers extension:
392388
class RedisBackedCacheIntTest extends Specification {
393389
```
394390

395-
And add the following field to the body of our test class:
391+
And add the following field to the body of the test class:
396392

397393
```groovy
398394
GenericContainer redis = new GenericContainer<>("redis:6-alpine")
@@ -401,20 +397,20 @@ GenericContainer redis = new GenericContainer<>("redis:6-alpine")
401397

402398
This tells Spock to start a Testcontainers `GenericContainer`, configured to use a specific Redis image from Docker Hub, and configured to expose a port.
403399

404-
If we run our test as-is, then regardless of the actual test outcome, we'll see logs showing us that Testcontainers:
400+
If you run the test as-is, then regardless of the actual test outcome, you'll see logs showing you that Testcontainers:
405401

406-
* was activated before our test method ran
407-
* discovered and quickly tested our local Docker setup
402+
* was activated before the test method ran
403+
* discovered and quickly tested the local Docker setup
408404
* pulled the image if necessary
409405
* started a new container and waited for it to be ready
410406
* shut down and deleted the container after the test
411407

412-
### Step 3: Make sure our code can talk to the container
408+
### Step 3: Make sure the code can talk to the container
413409

414-
Before Testcontainers, we might have hardcoded an address like `localhost:6379` into our tests.
410+
Before Testcontainers, you might have hard-coded an address like `localhost:6379` in the tests.
415411

416412
Testcontainers uses *randomized ports* for each container it starts, but makes it easy to obtain the actual port at runtime.
417-
We can do this in our test `setup` method, to set up our component under test:
413+
You can do this in your test `setup` method, to set up your component under test:
418414

419415
```groovy
420416
String address = redis.host
@@ -426,16 +422,14 @@ underTest = new RedisBackedCache(address, port)
426422

427423
> [!TIP]
428424
>
429-
> Notice that we also ask Testcontainers for the container's actual address with `redis.containerIpAddress`,
425+
> Notice that the previous code also asks Testcontainers for the container's actual address with `redis.containerIpAddress`,
430426
> rather than hard-coding `localhost`. `localhost` may work in some environments but not others - for example it may
431427
> not work on your current or future CI environment. As such, **avoid hard-coding** the address, and use
432428
> `containerIpAddress` instead.
433429
434430
### Step 4: Run the tests
435431

436-
That's it!
437-
438-
Let's look at our complete test class to see how little we had to add to get up and running with Testcontainers:
432+
Let's look at the complete test class to see how little you had to add to get up and running with Testcontainers:
439433

440434
```groovy
441435
@org.testcontainers.spock.Testcontainers

0 commit comments

Comments
 (0)