Repository navigation
refactor(tests): share the adapter test suite behind a common harness - #827
Open
LiamCarPer wants to merge 1 commit into
Open
LiamCarPer wants to merge 1 commit into
LiamCarPer wants to merge 1 commit into
Conversation
The broadcast, rooms, sockets and local test files were almost identical in the three adapters. Move the test bodies into a new adapter-test-suite crate with a Fixture trait, implemented by each adapter to spawn its servers, and keep the adapter specific tests where they are (postgres attachments, postgres/mongodb close, the redis targeted ack test). Each adapter test file is now a thin wrapper that runs the shared test with its fixture. Closes Totodore#825
Merging this PR will not alter performance1 warning
Comparing |
This branch has not been deployed
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.
Closes #825, part of #727.
Motivation
The redis, postgres and mongodb adapter test suites were almost the same code copied three times:
broadcast.rswas 96-97% identical,rooms.rs99%,sockets.rs86% andlocal.rs100%. A change or a fix had to be made three times, and the redis regression test from #782 is a good example of a test that only landed in one adapter.Solution
Added
crates/adapter-test-suite(publish = false, dev-dependency of the three adapters):Fixturetrait implemented by each adapter:spawn_servers,spawn_buggy_serversandadd_ns(the last one awaits the adapter init future, whose type/error differ per adapter).F: Fixture.timeout_rcv!,timeout_rcv_err!andassert_now!macros.Each adapter keeps its
fixture.rs(the stub driver) plus a smallFixtureimpl, and its test files are now thin wrappers like:Adapter specific tests stay where they are: postgres
attachments.rs, postgres/mongodbclose.rs, and the redisremote_socket_emit_with_ack_targeted_terminatestest from #782.This also drops a couple of debug leftovers that had been copied into the postgres/mongodb tests (
dbg!inrooms, atracing_subscriberinit inbroadcast) since the shared bodies use the redis versions.Tests
Same test count per adapter before and after (redis 29, postgres 29, mongodb 21).
cargo test --all-features --workspace,cargo clippy --all-features --workspace --examples --tests -- -D warningsandcargo fmt --checkare green.Net: ~670 lines removed.