test: deduplicate noOpTransactionRunner into shared test stubs#61
Merged
Conversation
The no-op TransactionRunner was copy-pasted as a file-private helper into six test files (2 in okapi-core, 4 in okapi-spring-boot). Consolidates each module's copies into one internal helper: - okapi-spring-boot: moved into the existing OkapiSpringTestStubs.kt, whose own KDoc already advocates this exact "single source" consolidation for the stubs. - okapi-core: new OkapiCoreTestStubs.kt mirroring that convention. One definition per module remains; collapsing to a single cross-module source would require Gradle test-fixtures wiring, which is out of scope here. Test-only, no behaviour change.
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
The no-op
TransactionRunnertest double was copy-pasted as a file-privatenoOpTransactionRunner()into 6 test files (2 inokapi-core, 4 inokapi-spring-boot). This consolidates each module's copies into a singleinternalhelper.OkapiSpringTestStubs.kt. That file's own KDoc already states the rationale ("Previously these were copy-pasted verbatim into 7+ test files; a single source means an … change is a one-line edit") — the no-op runner simply hadn't been folded in yet.OkapiCoreTestStubs.ktmirroring that convention.The 4 + 2 file-private definitions are removed; every call site now resolves to the shared
internal funin the same package (no imports needed at the call sites).Why one-per-module, not one total
Collapsing to a single cross-module definition would require
okapi-spring-boottest sources to consumeokapi-coretest code, i.e. Gradlejava-test-fixtures(or a dedicatedokapi-test-supportmodule) — infrastructure that is out of scope for a quick de-dup. One definition per module is the floor without that wiring.Test plan
./gradlew testClasses ktlintCheck— green (no orphaned imports;TransactionRunnerimport retained in all 6 files, still used bywithBean(TransactionRunner::class.java)/object : TransactionRunnerelsewhere)./gradlew :okapi-core:test :okapi-spring-boot:test— green (the autoconfig slice tests exercisenoOpTransactionRunner()heavily)Test-only; no behaviour change. Net −19 lines.