Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterise more tests across DataLoader implementations #171

Conversation

AlexandreCarlton
Copy link
Collaborator

We parameterise:

  • DataLoaderValueCacheTest
  • ScheduledDataLoaderRegistryTest

to provide increased coverage across all DataLoader implementations.

Notably, DataLoaderValueCacheTest is not parameterised across the Publisher DataLoaders (yet) as these do not appear to work when a ValueCache is provided (which is what prompted this pull request). It will be fixed in a future pull request, at which point we will restore coverage.

We parameterise:

 - `DataLoaderValueCacheTest`
 - `ScheduledDataLoaderRegistryTest`

to provide increased coverage across all DataLoader implementations.

Notably, `DataLoaderValueCacheTest` is _not_ parameterised across the
Publisher DataLoaders (yet) as these do not appear to work when a
`ValueCache` is provided (which is what prompted this pull request). It
will be fixed in a future pull request, at which point we will restore
coverage.
import java.util.stream.Stream;

public class TestDataLoaderFactories {
public static Stream<Arguments> get() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Lifted this to a central location so it could be used across multiple tests.

public void test_by_default_we_have_no_value_caching() {
List<List<String>> loadCalls = new ArrayList<>();
@ParameterizedTest
@MethodSource("org.dataloader.fixtures.parameterized.TestDataLoaderFactories#getWithoutPublisher")
Copy link
Collaborator Author

@AlexandreCarlton AlexandreCarlton Jan 1, 2025

Choose a reason for hiding this comment

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

As mentioned in the description, we use getWithoutPublisher rather than get as ValueCache does not appear to interact well with the Publisher DataLoaders. It is intended that this will be fixed eventually, in a separate PR (as this is already quite substantial).

@@ -61,43 +60,14 @@ public static <K, V> BatchLoader<K, V> keysAsValues(List<List<K>> loadCalls) {
};
}

public static <K, V> BatchLoader<K, V> keysAsValuesAsync(Duration delay) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Figured I'd clean up the now unused methods - we should be using the TestDataLoaderFactory-provided DataLoaders anyway, if we feel the need to reach out for these older ones.

@@ -19,4 +22,17 @@ public interface TestDataLoaderFactory {
DataLoader<String, String> onlyReturnsNValues(int N, DataLoaderOptions options, ArrayList<Object> loadCalls);

DataLoader<String, String> idLoaderReturnsTooMany(int howManyMore, DataLoaderOptions options, ArrayList<Object> loadCalls);

// Convenience methods
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Really, this was just to minimise the diff.

@bbakerman bbakerman merged commit 04db8d2 into graphql-java:master Jan 3, 2025
1 check passed
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