Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: generate Go examples for new modules #1600

Merged
merged 3 commits into from
Sep 6, 2023

Conversation

mdelapenya
Copy link
Member

  • chore: rename templates to module
  • chore: support generating Go Examples

What does this PR do?

This PR adds a new Go template for including a dedicated Go file for Go examples. This examples file will include just an example on how to run the module, with the RunContainer function.

We have updated the tests, modifying the docs template to embed the code snippet to run a container from the examples, instead of from the test code.

Why is it important?

It will open the gate to add executable code snippets as Go examples:

  • are published in the Go docs (see pkg.dev)
  • can be copy&pasted more easily than copying from a test code block

Related issues

Follow-ups

Visit all modules and example modules, adding an examples_test.go file, and finally linking the code snippets in the docs to the new testable Examples code blocks

@mdelapenya mdelapenya requested a review from a team as a code owner September 6, 2023 11:36
@mdelapenya mdelapenya added the documentation Docs, docs, docs. label Sep 6, 2023
@mdelapenya mdelapenya self-assigned this Sep 6, 2023
@netlify
Copy link

netlify bot commented Sep 6, 2023

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit d3b8017
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/64f864def05edc00096d08aa
😎 Deploy Preview https://deploy-preview-1600--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@@ -0,0 +1,36 @@
{{ $entrypoint := Entrypoint }}{{ $lower := ToLower }}{{ $title := Title }}package {{ $lower }}_test
Copy link
Member Author

@mdelapenya mdelapenya Sep 6, 2023

Choose a reason for hiding this comment

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

@mdelapenya
Copy link
Member Author

Merging, as the generator tests passed

mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 6, 2023
* chore: rename templates to module

* chore: support generating Go Examples

* fix: test
@mdelapenya
Copy link
Member Author

For some reason the merge happened but the PR was kept open 🤷

@mdelapenya mdelapenya merged commit da94001 into testcontainers:main Sep 6, 2023
@mdelapenya mdelapenya deleted the add-examples branch September 6, 2023 12:32
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Docs, docs, docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant