From bc4cec887b6328a58f46f07c57488513680533f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Tue, 22 Nov 2022 17:01:17 +0100 Subject: [PATCH 1/3] docs: document replace directive for Docker Compose (#632) * docs: document replace directive for Docker Compose * chore: convert it into a warning message * fix: use complete replace directive --- docs/quickstart/gotest.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/quickstart/gotest.md b/docs/quickstart/gotest.md index 2c2cb11b03..843548bf15 100644 --- a/docs/quickstart/gotest.md +++ b/docs/quickstart/gotest.md @@ -13,6 +13,31 @@ We use [gomod](https://blog.golang.org/using-go-modules) and you can get it inst go get github.com/testcontainers/testcontainers-go ``` +!!!warning + + Given the version includes the Compose dependency, and the Docker folks added [a replace directive until the upcoming Docker 22.06 release is out](https://github.com/docker/compose/issues/9946#issuecomment-1288923912), + we were forced to add it too, causing consumers of _Testcontainers for Go_ to add the following replace directive to their `go.mod` files. + We expect this to be removed in the next releases of _Testcontainers for Go_. + + ``` + replace ( + github.com/docker/cli => github.com/docker/cli v20.10.3-0.20221013132413-1d6c6e2367e2+incompatible // 22.06 master branch + github.com/docker/docker => github.com/docker/docker v20.10.3-0.20221013203545-33ab36d6b304+incompatible // 22.06 branch + github.com/moby/buildkit => github.com/moby/buildkit v0.10.1-0.20220816171719-55ba9d14360a // same as buildx + + github.com/opencontainers/runc => github.com/opencontainers/runc v1.1.2 // Can be removed on next bump of containerd to > 1.6.4 + + // For k8s dependencies, we use a replace directive, to prevent them being + // upgraded to the version specified in containerd, which is not relevant to the + // version needed. + // See https://github.com/docker/buildx/pull/948 for details. + // https://github.com/docker/buildx/blob/v0.8.1/go.mod#L62-L64 + k8s.io/api => k8s.io/api v0.22.4 + k8s.io/apimachinery => k8s.io/apimachinery v0.22.4 + k8s.io/client-go => k8s.io/client-go v0.22.4 + ) + ``` + ## 2. Spin up Redis ```go From c0a5cdfcd862180b951784932d82e47f673da405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Tue, 22 Nov 2022 17:01:36 +0100 Subject: [PATCH 2/3] docs: remove code snippets from main README (#631) We want to delegate it to the docs site, as it will be up-to-date --- README.md | 82 +------------------------------------------------------ 1 file changed, 1 insertion(+), 81 deletions(-) diff --git a/README.md b/README.md index a8637b15c8..5f0b59641e 100644 --- a/README.md +++ b/README.md @@ -6,85 +6,5 @@ _Testcontainers for Go_ is a Go package that makes it simple to create and clean automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers that should be run as part of a test and clean up those resources when the test is done. -Here's an example of a test that spins up an NGINX container validates that it returns 200 for the status code: - -```go -package main - -import ( - "context" - "fmt" - "net/http" - "testing" - - "github.com/testcontainers/testcontainers-go" - "github.com/testcontainers/testcontainers-go/wait" -) - -type nginxContainer struct { - testcontainers.Container - URI string -} - -func setupNginx(ctx context.Context) (*nginxContainer, error) { - req := testcontainers.ContainerRequest{ - Image: "nginx", - ExposedPorts: []string{"80/tcp"}, - WaitingFor: wait.ForHTTP("/"), - } - container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ - ContainerRequest: req, - Started: true, - }) - if err != nil { - return nil, err - } - - ip, err := container.Host(ctx) - if err != nil { - return nil, err - } - - mappedPort, err := container.MappedPort(ctx, "80") - if err != nil { - return nil, err - } - - uri := fmt.Sprintf("http://%s:%s", ip, mappedPort.Port()) - - return &nginxContainer{Container: container, URI: uri}, nil -} - -func TestIntegrationNginxLatestReturn(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test") - } - - ctx := context.Background() - - nginxC, err := setupNginx(ctx) - if err != nil { - t.Fatal(err) - } - - // Clean up the container after the test is complete - defer func() { - if err := nginxC.Terminate(ctx); err != nil { - t.Fatalf("failed to terminate container: %v", err) - } - }() - - resp, err := http.Get(nginxC.URI) - if resp.StatusCode != http.StatusOK { - t.Fatalf("Expected status code %d. Got %d.", http.StatusOK, resp.StatusCode) - } -} -``` - -Cleaning up your environment after test completion should be accomplished by deferring the container termination, e.g -`defer nginxC.Terminate(ctx)`. Reaper (Ryuk) is also enabled by default to help clean up. - -## Documentation - -More information about _Testcontainers for Go_ can be found in [./docs](./docs), which is rendered at +You can find more information about _Testcontainers for Go_ in the [./docs](./docs) directory, which is rendered at [golang.testcontainers.org](https://golang.testcontainers.org). From ebc3dec5ab7971d4d5c5a070e1b35c28238912ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Tue, 22 Nov 2022 17:01:49 +0100 Subject: [PATCH 3/3] chore: bump version in mkdocs (#630) --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index 4283d8d990..c759532df0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -62,4 +62,4 @@ nav: - Getting help: getting_help.md edit_uri: edit/main/docs/ extra: - latest_version: 0.15.0 + latest_version: 0.16.0