Skip to content

fix: circular dependency embed test suite#596

Open
1-leo wants to merge 3 commits intomasterfrom
fix/embed-test-suite
Open

fix: circular dependency embed test suite#596
1-leo wants to merge 3 commits intomasterfrom
fix/embed-test-suite

Conversation

@1-leo
Copy link
Copy Markdown
Contributor

@1-leo 1-leo commented Apr 29, 2026

Embeds the test suite into ndk package.
Exported via package:ndk/testing.dart

This is necessary because of embedding of sembast into ndk (circular dependency)
ndk -> test_suite -> ndk

Not super happy with this solution but i don't see other good options.

The package:ndk/testing.dart is used so we can export other test tools in the future => so others can use exposed tests for their db implementation etc.

Summary by CodeRabbit

  • Chores
    • Consolidated the cache manager test suite into the main NDK package, simplifying the monorepo structure by removing a separate test-suite package.
    • Updated test utilities to be accessible via package:ndk/testing.dart instead of a dedicated package.
    • Refreshed all test imports across the codebase to reference the new consolidated location.

Co-authored-by: Copilot <copilot@github.com>
@1-leo 1-leo requested review from frnandu and nogringo April 29, 2026 13:35
@1-leo 1-leo self-assigned this Apr 29, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6b5d2cee-dbda-494f-9bb4-9a8ec4f7bae4

📥 Commits

Reviewing files that changed from the base of the PR and between 9db9e60 and 96af6e3.

📒 Files selected for processing (6)
  • packages/ndk/lib/test_utils/cache_manager_test_suite.dart
  • packages/ndk_cache_manager_test_suite/.gitignore
  • packages/ndk_cache_manager_test_suite/CHANGELOG.md
  • packages/ndk_cache_manager_test_suite/LICENSE
  • packages/ndk_cache_manager_test_suite/README.md
  • packages/ndk_cache_manager_test_suite/pubspec.yaml
💤 Files with no reviewable changes (5)
  • packages/ndk_cache_manager_test_suite/LICENSE
  • packages/ndk_cache_manager_test_suite/.gitignore
  • packages/ndk_cache_manager_test_suite/pubspec.yaml
  • packages/ndk_cache_manager_test_suite/CHANGELOG.md
  • packages/ndk_cache_manager_test_suite/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/ndk/lib/test_utils/cache_manager_test_suite.dart

📝 Walkthrough

Walkthrough

Consolidates the standalone ndk_cache_manager_test_suite into packages/ndk/test_utils/, re-exports it via packages/ndk/lib/testing.dart, updates consumer tests to import package:ndk/testing.dart, and removes the separate test-suite package and workspace entry; adds Cashu-specific cache manager tests.

Changes

Cohort / File(s) Summary
Workspace & Manifests
pubspec.yaml, packages/drift/pubspec.yaml, packages/objectbox/pubspec.yaml, packages/ndk_cache_manager_test_suite/pubspec.yaml
Removed ndk_cache_manager_test_suite from workspace and from dev_dependencies; deleted the standalone package manifest.
Public re-export
packages/ndk/lib/testing.dart
Added re-export of test_utils/cache_manager_test_suite.dart to expose the test suite from ndk.
Test suite implementation
packages/ndk/lib/test_utils/cache_manager_test_suite.dart, packages/ndk/lib/test_utils/cache_manager_test_suite_cashu.dart
Added/updated cache manager test-suite files under ndk/test_utils/, including Cashu-specific observable CRUD tests and doc/import tweaks.
Consumer test imports
packages/drift/test/drift_cache_manager_test.dart, packages/ndk/test/data_layer/cache_manager/..., packages/objectbox/test/data_layer/cache_manager/objectbox_cache_manager_test.dart
Switched imports from package:ndk_cache_manager_test_suite/... to package:ndk/testing.dart (no test logic changes).
Removed package docs/metadata
packages/ndk_cache_manager_test_suite/CHANGELOG.md, .../LICENSE, .../README.md, .../.gitignore
Deleted README, LICENSE, CHANGELOG, and cleared .gitignore for the removed package.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • frnandu
  • nogringo

Poem

🐰 A hop, a tidy move from package to tree,
Tests bundled together, now home in ndk,
Cashu proofs and keysets checked with delight,
Imports swapped over, each test still runs right,
Happy Rabbit testing under the moonlight 🌙

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: fixing a circular dependency by embedding the test suite into the ndk package, which is reflected across all file changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/embed-test-suite

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/ndk/lib/test_utils/cache_manager_test_suite_cashu.dart`:
- Around line 76-79: Calls to getProofs are passing a nonexistent state argument
(e.g. CashuProofState.unspend); the method signature is getProofs({String?
mintUrl, String? keysetId}), so remove the state parameter from all
getProofs(...) invocations (for example the calls that currently look like
getProofs(mintUrl: 'https://test.mint.com', state: CashuProofState.unspend)) and
leave only the supported named args (mintUrl and/or keysetId); update every
occurrence in the test suite where getProofs is called with state (including the
other reported spots) so they match the actual getProofs signature.

In `@packages/ndk/lib/test_utils/cache_manager_test_suite.dart`:
- Around line 16-20: The example in runCacheManagerTestSuite uses the wrong
parameter name and implies wrong timing; update all examples (including the
snippets at lines mentioned) to use the correct parameter name cleanUp instead
of tearDown and state that cleanUp is invoked after each test (it is executed
via tearDown), e.g. mention cleanUp: (cacheManager) async => await
cacheManager.close(), and clarify in the doc text that cleanUp runs after every
test, not after the test group, referencing runCacheManagerTestSuite and the
cleanUp callback to locate the code to update.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2acbc84a-8c80-4303-9dfe-2405e397c2ff

📥 Commits

Reviewing files that changed from the base of the PR and between ea6fb60 and 9db9e60.

📒 Files selected for processing (10)
  • packages/drift/pubspec.yaml
  • packages/drift/test/drift_cache_manager_test.dart
  • packages/ndk/lib/test_utils/cache_manager_test_suite.dart
  • packages/ndk/lib/test_utils/cache_manager_test_suite_cashu.dart
  • packages/ndk/lib/testing.dart
  • packages/ndk/test/data_layer/cache_manager/mem_cache_manager_test.dart
  • packages/ndk/test/data_layer/cache_manager/sembast_cache_manager_test.dart
  • packages/objectbox/pubspec.yaml
  • packages/objectbox/test/data_layer/cache_manager/objectbox_cache_manager_test.dart
  • pubspec.yaml
💤 Files with no reviewable changes (3)
  • packages/drift/pubspec.yaml
  • packages/objectbox/pubspec.yaml
  • pubspec.yaml

Comment on lines +76 to +79
final loadedProofs = await cacheManager.getProofs(
mintUrl: 'https://test.mint.com',
state: CashuProofState.unspend,
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== CacheManager method signatures =="
rg -n --type=dart -C2 'Future<.*>\s+getProofs\s*\(|Future<.*>\s+getMintInfos\s*\(' packages/ndk/lib/domain_layer/repositories/cache_manager.dart

echo
echo "== Named-argument usage in shared cashu suite =="
rg -n --type=dart -C2 'getProofs\s*\(|getMintInfos\s*\(' packages/ndk/lib/test_utils/cache_manager_test_suite_cashu.dart

Repository: relaystr/ndk

Length of output: 2190


Remove undeclared state parameter from getProofs() calls.

The method signature is getProofs({String? mintUrl, String? keysetId}) but these calls pass a state parameter that does not exist in the interface. Update all calls to match the actual signature.

Affected lines: 76–79, 116–119, 123–126, 200–201, 204–205.

Note: getMintInfos(mintUrls: ...) calls are correct.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ndk/lib/test_utils/cache_manager_test_suite_cashu.dart` around lines
76 - 79, Calls to getProofs are passing a nonexistent state argument (e.g.
CashuProofState.unspend); the method signature is getProofs({String? mintUrl,
String? keysetId}), so remove the state parameter from all getProofs(...)
invocations (for example the calls that currently look like getProofs(mintUrl:
'https://test.mint.com', state: CashuProofState.unspend)) and leave only the
supported named args (mintUrl and/or keysetId); update every occurrence in the
test suite where getProofs is called with state (including the other reported
spots) so they match the actual getProofs signature.

Comment thread packages/ndk/lib/test_utils/cache_manager_test_suite.dart
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.04%. Comparing base (c96e332) to head (96af6e3).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #596      +/-   ##
==========================================
+ Coverage   72.20%   74.04%   +1.84%     
==========================================
  Files         201      203       +2     
  Lines       10144    10874     +730     
==========================================
+ Hits         7324     8052     +728     
- Misses       2820     2822       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants