Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

chore: replicate the existing tests using testcontainers-go #7

Closed
wants to merge 6 commits into from

Conversation

mdelapenya
Copy link

@mdelapenya mdelapenya commented Dec 5, 2022

What does this PR do?

It creates a separate main_testcontainers_test.go file with copies of the very same tests as in main_test.go. These new tests use a Go build tag in order to separate their execution from the existing tests, therefore it's possible to run both test suites separately:

# dockertests only
$ go test ./... -count=1 -tags=dockertest
# testcontainers only
$ go test ./... -count=1 -tags=testcontainers

The new tests are created using testcontainers-go, showcasing an alternative to ory/dockertest on how to test Docker containers with Testcontainer for Go.

Finally, it bumps the Go version from Go 1.16 to 1.18

Why is it important?

As we explained in #6, we don't want to replace, but coexist in this application, which is used by the Go tutorial in the Docker docs.

Related issues

Follows-up

As described in docker/docs#16221, we'd like to contribute to the Go tutorial in the Docker docs, including a section for Testcontainers for Go.

gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
github.com/ory/dockertest/v3 v3.6.5
github.com/stretchr/testify v1.8.0
github.com/testcontainers/testcontainers-go v0.15.0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using previous version instead of latest 0.16.0 meanwhile we resolve the dependency issues from the native Docker Compose support we introduced in the latest release.

@mdelapenya
Copy link
Author

@olliefr is there anything that we could do to merge this one? Please see docker/docs#16221 (comment) for more context

@olliefr
Copy link
Owner

olliefr commented Mar 11, 2023

Hello! While working on #8 I have made a decision to remove the dependency on ory/dockertest altogether and replace the existing functional tests with a trivial unit test example.

This is because I feel that in the context of a short tutorial such as the Golang section of Docker docs, those two tests were too extensive and were not adding pedagogical value, and partly because no matter what framework or what testing methodology I would have chosen, it would get out-of-date pretty quickly regardless.

Since the point of that page was not to show "one true way" of how to test Go applications but to demonstrate multi-stage Docker builds, I made a decision to remove the tests. This will also reduce maintenance burden significantly. I plan to update the docs on the topic of testing to provide a few references to popular Go testing frameworks, including testcontainers, but I don't think that this example application needs automatic testing beyond a trivial example that I have just added in the latest update.

I realise that you have spent some time working on this PR and I thank you for your efforts. I'll make sure that I mention testcontainers in the doc page.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding Testconstainers for Go
2 participants