Repository navigation
test: add unit test suite and CI - #1
Merged
Merged
Conversation
Cover every module with focused unit tests (70 total, ~1.5s, no network, real browser, or ~/.portmap access): - scan: lsof/ps output parsing, runtime/system/desktop classification, project detection, and HTTP probing against scripted loopback servers - store: entry lifecycle, persistence round-trip, orphan thumbnail sweep, expiry rules, and view versioning - scanner: probe caching, stale/expiry transitions, thumbnail scheduling, and batching of refresh requests - server: Host/Origin guards, every action, and the HTTP API end to end - thumbs: capture via a stub browser, sips conversion, failure backoff - launchd plist rendering and CLI argument parsing Small refactors separate pure logic from subprocess and socket calls so it can be tested; behavior is unchanged. Fixes found by the new tests: - probe() reported servers with 3+ chained redirects as non-HTTP - the thumbnail worker captured hidden services and restored thumbnails the user had just removed by hiding them CI runs fmt, clippy, and tests on macOS for every push and pull request.
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.
The project had four small parsing tests. This adds a suite covering every module, two bug fixes the tests turned up, and CI to run it.
Tests (70, about 1.5s)
None of them use the network, a real browser, or
~/.portmap. Probes and the HTTP API run against real sockets on ephemeral loopback ports. Thumbnail capture uses a stub "browser" shell script, and persistence uses throwaway directories. Shared fixtures are insrc/testutil.rs.lsof/psoutput, runtime/system/desktop-app classification, project detection on a temp directory tree, and HTTP probing (titles, redirects, non-HTTP listeners, address fallback, closed ports)./api/refreshwaiting for a scan, thumbnail serving).sipsJPEG conversion on macOS, failure backoff, skipped work.--portparsing.Refactors
These pull pure logic out of subprocess and socket code so it can be tested:
parse_listeners/parse_ps_args/parse_cwds, scannerrelevant/update/run_with, serverserve/host_allowed/mutation_allowed,plist(), andparse_args(). Behavior is unchanged, except that a malformedlsofline starting with a multi-byte character is now skipped instead of panicking.Bug fixes found by the tests
probe()reported a server with 3 or more chained redirects as non-HTTP, so it showed up under "other" instead of as a card. The last hop's response is now reported as-is.hidden. A service hidden while queued, or during a capture, got a screenshot anyway, which brought back the thumbnail that hiding had just deleted.Verification
cargo testpassed 10 times in a row locally. Clippy (-D warnings) andcargo fmt --checkare clean.Known follow-up (not in this PR)
A scan saves
state.jsononly when the visible view changes, solast_seenfor a long-running, unchanged service isn't persisted. If portmap restarts abruptly and the service is gone by then, its bookmark is cleared immediately instead of after the stale TTL. Fixing this needs periodic state writes, which is a separate design decision.