-
Notifications
You must be signed in to change notification settings - Fork 90
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
Parameterise more tests across DataLoader implementations #171
Conversation
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() { |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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
DataLoader
s. 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) { |
There was a problem hiding this comment.
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 DataLoader
s 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 |
There was a problem hiding this comment.
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.
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 aValueCache
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.