docs: use Go testable examples in modules#1603
Merged
mdelapenya merged 39 commits intotestcontainers:mainfrom Sep 11, 2023
Merged
docs: use Go testable examples in modules#1603mdelapenya merged 39 commits intotestcontainers:mainfrom
mdelapenya merged 39 commits intotestcontainers:mainfrom
Conversation
They are not directly called, but the customisers are populating their values
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
…ult (testcontainers#1566) * chore(deps): bump github.com/hashicorp/vault-client-go in /modules/vault Bumps [github.com/hashicorp/vault-client-go](https://github.com/hashicorp/vault-client-go) from 0.2.0 to 0.3.3. - [Release notes](https://github.com/hashicorp/vault-client-go/releases) - [Changelog](https://github.com/hashicorp/vault-client-go/blob/main/CHANGELOG.md) - [Commits](hashicorp/vault-client-go@v0.2.0...v0.3.3) --- updated-dependencies: - dependency-name: github.com/hashicorp/vault-client-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * up * Update vault_test.go * Update vault_test.go * Update vault_test.go * Update vault_test.go * Update vault_test.go --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Manuel de la Peña <[email protected]>
Signed-off-by: Matthieu MOREL <[email protected]>
* ci(lint): enable errorlint linter Signed-off-by: Matthieu MOREL <[email protected]> * Apply suggestions from code review Co-authored-by: Manuel de la Peña <[email protected]> --------- Signed-off-by: Matthieu MOREL <[email protected]> Co-authored-by: Manuel de la Peña <[email protected]>
* main: ci(lint): enable errorlint linter (testcontainers#1604) ci(lint): enable gocritic linter (testcontainers#1605) chore(deps): bump github.com/hashicorp/vault-client-go in /modules/vault (testcontainers#1566)
This reverts commit 0e28881.
|
Kudos, SonarCloud Quality Gate passed!
|
mdelapenya
commented
Sep 11, 2023
| defaultWaitStrategies.Strategies = append( | ||
| defaultWaitStrategies.Strategies, | ||
| // clone defaultWaitStrategies | ||
| ss := []wait.Strategy{ |
Member
Author
There was a problem hiding this comment.
I discovered a bug here in the case the tests were run sequentially, as the default strategies variable was overridden, causing the with_transactions test case to fail because it was expecting the wait strategy for with_functions_workers. Fixing it here to avoid the test failures that were discovered on this PR
mdelapenya
commented
Sep 11, 2023
| // printLogs is a helper function that will print the logs of a Docker container | ||
| // We are going to use this helper function to inform the user of the logs when an error occurs | ||
| func (c *DockerContainer) printLogs(ctx context.Context) { | ||
| func (c *DockerContainer) printLogs(ctx context.Context, cause error) { |
Member
Author
There was a problem hiding this comment.
Needed to print out the original error that caused the hooks to stop
mdelapenya
added a commit
that referenced
this pull request
Sep 12, 2023
…containerd-1.7.5 * main: chore: always generate the examples including a explicit image (#1611) chore: support linting all modules locally (#1609) ci(sonarcloud): run only when not root-less (#1608) remove extra equal in sonar.organization (#1607) chore(ci): enable code coverage on Sonarcloud (#1518) docs: use Go testable examples in modules (#1603)
mdelapenya
added a commit
to mdelapenya/testcontainers-go
that referenced
this pull request
Sep 12, 2023
* main: chore: always generate the examples including a explicit image (testcontainers#1611) chore: support linting all modules locally (testcontainers#1609) ci(sonarcloud): run only when not root-less (testcontainers#1608) remove extra equal in sonar.organization (testcontainers#1607) chore(ci): enable code coverage on Sonarcloud (testcontainers#1518) docs: use Go testable examples in modules (testcontainers#1603) ci(lint): enable errorlint linter (testcontainers#1604) ci(lint): enable gocritic linter (testcontainers#1605) chore(deps): bump github.com/hashicorp/vault-client-go in /modules/vault (testcontainers#1566) ci(security): setup codeql scan (testcontainers#1606) chore(deps): bump github.com/cyphar/filepath-securejoin (testcontainers#1601) chore: generate Go examples for new modules (testcontainers#1600) chore: generate Go examples for new modules (testcontainers#1600)
ttruongatl
pushed a commit
to ttruongatl/testcontainers-go
that referenced
this pull request
Feb 15, 2025
* fix: rename vault container in tests * chore: adjust comment in template * docs(vault): use RunContainer example in usage section * docs: update vault docs * docs: add RunContainer example for redpanda * docs: add RunContainer example for redis * docs: document creating networks * docs: add RunContainer example for pulsar * docs: add RunContainer example for postgres * docs: add RunContainer example for neo4j * docs: add RunContainer example for nats * docs: update quickstart to not use testing libraries * docs: add RunContainer example for mysql * docs: add RunContainer example for mongo * docs: add RunContainer example for mariadb * chore: use logger to print out hostname external reason * docs: document new Go examples file * docs: add RunContainer example for localstack * chore: convert k3s test into a testable example * chore: convert mongodb test into testable example * fix: handle errors in example tests for elasticsearch * fix: do not deprecate used fields They are not directly called, but the customisers are populating their values * chore: convert couchbase test into testable example * chore: convert clickhouse test into testable example * docs: adjust artemis docs * chore: simplify postgres example * fix: lint * chore(deps): bump github.com/hashicorp/vault-client-go in /modules/vault (testcontainers#1566) * chore(deps): bump github.com/hashicorp/vault-client-go in /modules/vault Bumps [github.com/hashicorp/vault-client-go](https://github.com/hashicorp/vault-client-go) from 0.2.0 to 0.3.3. - [Release notes](https://github.com/hashicorp/vault-client-go/releases) - [Changelog](https://github.com/hashicorp/vault-client-go/blob/main/CHANGELOG.md) - [Commits](hashicorp/vault-client-go@v0.2.0...v0.3.3) --- updated-dependencies: - dependency-name: github.com/hashicorp/vault-client-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * up * Update vault_test.go * Update vault_test.go * Update vault_test.go * Update vault_test.go * Update vault_test.go --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Manuel de la Peña <[email protected]> * ci(lint): enable gocritic linter (testcontainers#1605) Signed-off-by: Matthieu MOREL <[email protected]> * ci(lint): enable errorlint linter (testcontainers#1604) * ci(lint): enable errorlint linter Signed-off-by: Matthieu MOREL <[email protected]> * Apply suggestions from code review Co-authored-by: Manuel de la Peña <[email protected]> --------- Signed-off-by: Matthieu MOREL <[email protected]> Co-authored-by: Manuel de la Peña <[email protected]> * fix: handle errors * chore(pulsar): create/remove the network properly * chore: better container logs on errors during startup * Revert "chore: better container logs on errors during startup" This reverts commit 0e28881. * chore: better container logs on errors during startup * fix: do not wrap error but print it * fix: avoid polluting default wait strategies in pulsar --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Matthieu MOREL <[email protected]> Co-authored-by: Matthieu MOREL <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








What does this PR do?
This PR adds a
examples_test.gofile in all Go modules, adding there testable examples (func ExampleRunContainer())At the same time, we are adapting the code snippets that are embedded into the docs site to use this example functions instead of the test ones. In certain cases, we have refactored the test cases to follow a better structure that adapts to the testable examples.
We are aware that some Example functions could be duplication other existing tests, that's way we have removed those that collided.
During the refactor of the docs, we found useful to include docs on how to create a Docker network using the library, so docs have been added for that feature.
Why is it important?
The code snippets in docs won't contain references to testing libraries such as
testingortestify, and the examples will appear in pgk.go.dev, which is important for our users to see real, executable test examples.Related issues