Skip to content

test: deduplicate noOpTransactionRunner into shared test stubs#61

Merged
endrju19 merged 1 commit into
mainfrom
chore-dedup-nooptransactionrunner
Jun 5, 2026
Merged

test: deduplicate noOpTransactionRunner into shared test stubs#61
endrju19 merged 1 commit into
mainfrom
chore-dedup-nooptransactionrunner

Conversation

@endrju19
Copy link
Copy Markdown
Collaborator

@endrju19 endrju19 commented Jun 5, 2026

Summary

The no-op TransactionRunner test double was copy-pasted as a file-private noOpTransactionRunner() into 6 test files (2 in okapi-core, 4 in okapi-spring-boot). This consolidates each module's copies into a single internal helper.

  • okapi-spring-boot → moved into the existing 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.
  • okapi-core → new OkapiCoreTestStubs.kt mirroring that convention.

The 4 + 2 file-private definitions are removed; every call site now resolves to the shared internal fun in 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-boot test sources to consume okapi-core test code, i.e. Gradle java-test-fixtures (or a dedicated okapi-test-support module) — 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; TransactionRunner import retained in all 6 files, still used by withBean(TransactionRunner::class.java) / object : TransactionRunner elsewhere)
  • ./gradlew :okapi-core:test :okapi-spring-boot:test — green (the autoconfig slice tests exercise noOpTransactionRunner() heavily)

Test-only; no behaviour change. Net −19 lines.

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.
@endrju19 endrju19 merged commit 9922a99 into main Jun 5, 2026
8 checks passed
@endrju19 endrju19 deleted the chore-dedup-nooptransactionrunner branch June 5, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant