refactor: deduplicate shared test helpers#1399
Open
ericcurtin wants to merge 1 commit into
Open
Conversation
Collaborator
|
/ok to test 9a8ee87 |
|
Label |
Contributor
Author
|
@johntmyers I wonder can you give me better privileges so the builds can automatically run. Your call of course! |
Contributor
Author
|
Trying to fix CI now |
9a8ee87 to
f36fef5
Compare
Extract four categories of copy-pasted test code into single canonical locations: - POLICY_OBJECT_TYPE / DRAFT_CHUNK_OBJECT_TYPE constants that were defined identically in both persistence/sqlite.rs and persistence/postgres.rs are now owned by persistence/mod.rs. - test_server_state() was duplicated across grpc/provider.rs, grpc/policy.rs, and grpc/sandbox.rs. A shared grpc::test_support module in grpc/mod.rs now owns the single implementation; each submodule imports it. - The TestOpenShell stub (full OpenShell trait impl), install_rustls_provider(), PkiBundle, generate_pki(), and start_test_server() were copied across up to five openshell-server integration test files. A new tests/common/mod.rs module owns them; each test file uses mod common. - StubResponse, unique_socket_path(), and spawn_podman_stub() were duplicated between openshell-driver-podman/src/driver.rs and openshell-driver-podman/src/grpc.rs. A new src/test_utils.rs (cfg(test)-gated) owns the shared helpers.
f36fef5 to
0ff3511
Compare
Collaborator
|
/ok to test 0ff3511 |
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.
Summary
Extract four categories of copy-pasted test code into single canonical locations, removing ~1740 lines of duplication across
openshell-serverandopenshell-driver-podman.Related Issue
N/A — cleanup identified by scanning the codebase.
Changes
POLICY_OBJECT_TYPE/DRAFT_CHUNK_OBJECT_TYPEconstants: defined identically in bothpersistence/sqlite.rsandpersistence/postgres.rs; promoted topersistence/mod.rsand imported in both store files.test_server_state()helper: was duplicated acrossgrpc/provider.rs,grpc/policy.rs, andgrpc/sandbox.rs. A sharedgrpc::test_supportmodule ingrpc/mod.rsnow owns the single implementation; each submodule imports it.TestOpenShellstub + PKI helpers: the fullOpenShelltrait stub (400 lines),install_rustls_provider(),PkiBundle,generate_pki(), andstart_test_server()were copied across fiveopenshell-serverintegration test files. A newtests/common/mod.rsowns them all; each test file doesmod common.Podman stub helpers:
StubResponse,unique_socket_path(), andspawn_podman_stub()were duplicated betweendriver.rsandgrpc.rsinopenshell-driver-podman. A newsrc/test_utils.rs(cfg-gated to tests) owns the shared helpers.Testing
mise run pre-commitpasses (format + lint) for affected cratescargo test -p openshell-server -p openshell-driver-podman)Checklist