-
Notifications
You must be signed in to change notification settings - Fork 69
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
Validate: refactor internal methods to use fs.FS
interface for file handling
#413
Conversation
…patability." This reverts commit 9c92c3e.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @SBGoods! Makes our lives much easier moving forward 👍🏻
I had one question about the hardcoded slashes, but everything else looks great! 🚀
result = errors.Join(result, err) | ||
|
||
} | ||
if dirExists(filepath.Join(v.providerDir, filepath.Join("website", "docs"))) { | ||
if dirExists(v.providerFS, "website/docs") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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 thevalidateStaticDocs()
andvalidateLegacyWebsite()
to use afs.FS
interface for filesystem operations, and refactors the tests to use afstest.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:
index.md
files instead ofindex.*
files.