Skip to content

[mdatagen] Add a generated test calling NewFactory().createDefaultConfig().Validate() #12715

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

Open
atoulme opened this issue Mar 24, 2025 · 2 comments

Comments

@atoulme
Copy link
Contributor

atoulme commented Mar 24, 2025

This test should ensure the following:

  • We can call the Validate() function in an idempotent manner (meaning, the Config object is not modified by a call to Validate)
  • The Validate() call does not depend on external resources such as network calls.
@krisztianfekete
Copy link

Trying to wrap my head around mdatagen conventions, let me know if my thinking makes sense:

  • This is about adding the idempotency test in cmd/mdatagen/internal/templates/component_test.go.tmpl, so it can be re-used across components since they implement Config interface with Validate()
  • The test should call Validate() multiple times, comparing results/warnings, etc. to see whether those has changed or not, this should be straightforward
  • Re. external dependencies: do you have any specific approach in mind?

@atoulme
Copy link
Contributor Author

atoulme commented Mar 25, 2025

No specific approach, but any call out to an authenticated resource such as aws ec2 metadata services or an environment variable will fail (though, I did add env var support for tests).

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

No branches or pull requests

2 participants