terraform-plugin-docs
terraform-plugin-docs copied to clipboard
Validate: refactor internal methods to use `fs.FS` interface for file handling
Previously, the internal methods and checks for the validate
command were reading files/directories from file paths, which made internal unit testing difficult as it required static files and directories for each test case. This made it difficult to test new schema concepts with confidence. This PR refactors the validateStaticDocs()
and validateLegacyWebsite()
to use a fs.FS
interface for filesystem operations, and refactors the tests to use a fstest.MapFS
as an in-memory filesystem along with additional integration tests for the various validation checks.
There were several bugs that came up during testing which have fixes in this PR:
- File extension check was only being run on
index.md
files instead ofindex.*
files. - File extension check was outputting the incorrect valid extensions it's error message.
- Frontmatter checks were not being run with the correct options on legacy index files.