Skip to content

Conversation

@pavan-traceable
Copy link
Contributor

Description

Fixed the bug around user filters in document config store

@pavan-traceable pavan-traceable requested a review from a team as a code owner April 22, 2025 10:35
@github-actions
Copy link

github-actions bot commented Apr 22, 2025

Test Results

139 tests  +4   139 ✅ +4   1m 1s ⏱️ +4s
 31 suites ±0     0 💤 ±0 
 31 files   ±0     0 ❌ ±0 

Results for commit 1ea8313. ± Comparison against base commit 1ca592c.

♻️ This comment has been updated with latest results.

}

private Query buildQuery(
Query buildQuery(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - don't expose a method just to test it. Test it through the public interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's bit involved to write cases with public interface, can take it up as next PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Next PR is fine.

As far as what to change, one option would be to extract a query builder class, in which case testing that makes sense in a unit test (while tests on the store would start mocking it). But an even easier option... this test could just call getAllConfigs instead - it passes the same 4 arguments through to the query builder directly. Then just verify the call to collection.query.

Copy link
Contributor Author

@pavan-traceable pavan-traceable Apr 23, 2025

Choose a reason for hiding this comment

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

Thanks, since i need to wait for one more day to get it merged, i thought of doing in next PR. Anyway i have addressed all the comments. We should also take decision to remove sorting on ConfigVersion, i don't its needed any more.


Query query = configStore.buildQuery(configResource, filter, pagination, sortByList);

assertEquals(2, query.getSorts().size());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - compare the whole list rather than each element individually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Contributor

@aaron-steinfeld aaron-steinfeld Apr 22, 2025

Choose a reason for hiding this comment

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

this change will also removes the need to compare the size and applies to each test, both of which we can update here (separate PR is fine if you're following up anyway, no functional impact). The main benefit is that failures show up as a list diff (e.g. "expected [x, y], got []") rather than a more opaque failure like "expected 2, got 0"

@pavan-traceable pavan-traceable enabled auto-merge (squash) April 22, 2025 16:41
Copy link
Contributor

@aaron-steinfeld aaron-steinfeld left a comment

Choose a reason for hiding this comment

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

Disabled auto merge (so you can review the comments before deciding whether to merge - please do not use automerge until code has been approved), but if you want to take the comments in a follow up that's fine.

configStore.getAllConfigs(configResource, filter, pagination, sortByList);

// Capture the Query object passed to collection.query
ArgumentCaptor<Query> queryCaptor = ArgumentCaptor.forClass(Query.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

arg captors aren't needed here (they're almost always overkill). Let me post a branch to illustrate what I was suggesting

Copy link
Contributor

Choose a reason for hiding this comment

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

#290

If that looks good to you, feel free to merge it into your branch (or just take bits and pieces)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have merged your PR. Thanks for that.

@pavan-traceable pavan-traceable enabled auto-merge (squash) April 23, 2025 16:49
@pavan-traceable pavan-traceable merged commit f8e72f5 into main Apr 23, 2025
8 checks passed
@pavan-traceable pavan-traceable deleted the bugfix-user-filters branch April 23, 2025 16:50
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.

3 participants