Skip to content

Commit 1cc3482

Browse files
committed
Add new test using a different internal port
1 parent d328536 commit 1cc3482

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/testcontainers/src/socat/socat-container.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,28 @@ describe("Socat", { timeout: 120_000 }, () => {
2222
expect(response.status).toBe(200);
2323
expect(await response.text()).toBe("PONG");
2424

25+
await socat.stop();
26+
await helloworld.stop();
27+
await network.stop();
28+
});
29+
it("should forward requests to helloworld container in a different port", async () => {
30+
const network = await new Network().start();
31+
32+
const helloworld = await new GenericContainer("testcontainers/helloworld:1.2.0")
33+
.withExposedPorts(8080)
34+
.withNetwork(network)
35+
.withNetworkAliases("helloworld")
36+
.start();
37+
38+
const socat = await new SocatContainer().withNetwork(network).withTarget(8081, "helloworld", 8080).start();
39+
40+
const socatUrl = `http://${socat.getHost()}:${socat.getMappedPort(8081)}`;
41+
42+
const response = await fetch(`${socatUrl}/ping`);
43+
44+
expect(response.status).toBe(200);
45+
expect(await response.text()).toBe("PONG");
46+
2547
await socat.stop();
2648
await helloworld.stop();
2749
await network.stop();

0 commit comments

Comments
 (0)