Add tests for handler core, template rendering, and query validation#30
Merged
Add tests for handler core, template rendering, and query validation#30
Conversation
5ff69bf to
357cf62
Compare
638cfe6 to
d820f75
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three areas that were previously only tested indirectly now have direct coverage.
handler_test.go: Tests GetOrFetchArtifact and GetOrFetchArtifactFromURL cache hit/miss/error paths with mock storage and fetcher. Tests ServeArtifact response headers (Content-Type, Content-Length, ETag) and JSONError formatting. Tests NewProxy nil logger default.
templates_test.go: Renders every page template (dashboard, install, search, packages_list, package_show, version_show, browse_source, compare_versions) with representative data and verifies they produce valid HTML without errors. Tests unknown page returns error. Tests helper functions (getStripPrefix, ecosystemBadgeLabel, ecosystemBadgeClasses, formatSize, categorizeLicense).
Also adds integration tests for install page, package show 404, version show 404, search empty query redirect, search pagination edge cases, and ecosystem filtering.