From 88a3ddf3f3e0754136066c6e7b21be81d62c5fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Wed, 6 Jul 2022 07:49:01 +0200 Subject: [PATCH 1/2] docs: fix format between sections --- docs/features/creating_container.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/features/creating_container.md b/docs/features/creating_container.md index ee2ad64308..083f6038d6 100644 --- a/docs/features/creating_container.md +++ b/docs/features/creating_container.md @@ -138,9 +138,9 @@ if err != nil { log.Fatal(err) } fmt.Println(c) -```` +``` -# Parallel running +## Parallel running `testcontainers.ParallelContainers` - defines the containers that should be run in parallel mode. From 81567e60ff1ba9c1df7c421d9076fe4b572c30b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Wed, 6 Jul 2022 07:49:39 +0200 Subject: [PATCH 2/2] docs: consistency with tab indents --- docs/features/creating_container.md | 47 +++++++++++++++++------------ 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/docs/features/creating_container.md b/docs/features/creating_container.md index 083f6038d6..ae1fea8d58 100644 --- a/docs/features/creating_container.md +++ b/docs/features/creating_container.md @@ -91,24 +91,33 @@ the function will create a new generic container. If `Reuse` is true and `Name` The following test creates an NGINX container, adds a file into it and then reuses the container again for checking the file: ```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/testcontainers/testcontainers-go" +) const ( - reusableContainerName = "my_test_reusable_container" + reusableContainerName = "my_test_reusable_container" ) ctx := context.Background() n1, err := GenericContainer(ctx, GenericContainerRequest{ - ContainerRequest: ContainerRequest{ - Image: "nginx:1.17.6", - ExposedPorts: []string{"80/tcp"}, - WaitingFor: wait.ForListeningPort("80/tcp"), - Name: reusableContainerName, - }, - Started: true, + ContainerRequest: ContainerRequest{ + Image: "nginx:1.17.6", + ExposedPorts: []string{"80/tcp"}, + WaitingFor: wait.ForListeningPort("80/tcp"), + Name: reusableContainerName, + }, + Started: true, }) if err != nil { - log.Fatal(err) + log.Fatal(err) } defer n1.Terminate(ctx) @@ -116,26 +125,26 @@ copiedFileName := "hello_copy.sh" err = n1.CopyFileToContainer(ctx, "./testresources/hello.sh", "/"+copiedFileName, 700) if err != nil { - log.Fatal(err) + log.Fatal(err) } n2, err := GenericContainer(ctx, GenericContainerRequest{ - ContainerRequest: ContainerRequest{ - Image: "nginx:1.17.6", - ExposedPorts: []string{"80/tcp"}, - WaitingFor: wait.ForListeningPort("80/tcp"), - Name: reusableContainerName, + ContainerRequest: ContainerRequest{ + Image: "nginx:1.17.6", + ExposedPorts: []string{"80/tcp"}, + WaitingFor: wait.ForListeningPort("80/tcp"), + Name: reusableContainerName, }, - Started: true, + Started: true, Reuse: true, }) if err != nil { - log.Fatal(err) + log.Fatal(err) } c, _, err := n2.Exec(ctx, []string{"bash", copiedFileName}) if err != nil { - log.Fatal(err) + log.Fatal(err) } fmt.Println(c) ``` @@ -201,4 +210,4 @@ func main() { defer c.Terminate(ctx) } } -``` \ No newline at end of file +```