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

Document use of tests for resourcedocsgen tool #5998

Open
guineveresaenger opened this issue Nov 14, 2024 · 1 comment
Open

Document use of tests for resourcedocsgen tool #5998

guineveresaenger opened this issue Nov 14, 2024 · 1 comment
Labels
kind/engineering Work that is not visible to an external user

Comments

@guineveresaenger
Copy link
Contributor

#5931 added tests for resourcedocgen. 🎉

For the developer, the setup of these tests includes some context that is not immediately obvious.

Since we do not have a standardized way to do tests, it's really important that tests have:

  • Setup instructions
  • Documentation on what to avoid when writing new tests
  • How to re-generate the golden files
@pulumi-bot pulumi-bot added the needs-triage Needs attention from the triage team label Nov 14, 2024
@github-project-automation github-project-automation bot moved this to 🤔 Triage in Docs 📚 Nov 14, 2024
@mjeffryes mjeffryes added kind/engineering Work that is not visible to an external user and removed needs-triage Needs attention from the triage team labels Nov 16, 2024
@thoward thoward removed this from Docs 📚 Nov 18, 2024
@iwahbe
Copy link
Member

iwahbe commented Nov 19, 2024

For the developer, the setup of these tests includes some context that is not immediately obvious.

I'm not sure what you mean by "setup". The caveat for using that function is called out at the function declaration, as is how to regenerate:

// AssertDirEqual asserts that each file located under root is byte-for-byte identical
// with it's test representation.
//
// To update files under test, use:
//
// go test ./... -update
//
// WARNING: Multiple AssertDirEqual should not run in the same go test. If you need to
// call AssertDirEqual more then once in a test, place each in a subtest:
//
// t.Run("docs", func(t *testing.T) { util.AssertDirEqual(t, baseDocsOutDir) })
// t.Run("tree", func(t *testing.T) { util.AssertDirEqual(t, basePackageTreeJSONOutDir) })
func AssertDirEqual(t *testing.T, root string) {

That's only relevant when writing new tests using this function. When running tests, you just need to run the test like any other Go test:

$ cd tools/resourcedocsgen && go test ./...

We can call out how to run tests and -update in the README.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/engineering Work that is not visible to an external user
Projects
None yet
Development

No branches or pull requests

4 participants