Validate: refactor internal methods to use fs.FS interface for file handling#413
Validate: refactor internal methods to use fs.FS interface for file handling#413
fs.FS interface for file handling#413Conversation
…patability." This reverts commit 9c92c3e.
austinvalle
left a comment
There was a problem hiding this comment.
Awesome work @SBGoods! Makes our lives much easier moving forward 👍🏻
I had one question about the hardcoded slashes, but everything else looks great! 🚀
|
|
||
| } | ||
| if dirExists(filepath.Join(v.providerDir, filepath.Join("website", "docs"))) { | ||
| if dirExists(v.providerFS, "website/docs") { |
There was a problem hiding this comment.
Just to clarify my understanding, removing all the filepath.Join and replacing with hardcoded forward slashes is because we are always going against the fs.FS abstraction now right? So we don't need to worry about OS specific paths.
Should these just all be using the path package?
There was a problem hiding this comment.
Yes, as far as the internal usages go, we should be using forward slashes instead of filepath.Join. For the error messages though, whenever we print out the path, we convert the slashes back to the OS separator so that it isn't confusing to Windows developers. So test assertions for error messages should still use filepath.Join (this is also why the testscript tests are skipped on Windows).
Previously, the internal methods and checks for the
validatecommand 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 thevalidateStaticDocs()andvalidateLegacyWebsite()to use afs.FSinterface for filesystem operations, and refactors the tests to use afstest.MapFSas 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:
index.mdfiles instead ofindex.*files.