fix(flutter/test): tolerate Riverpod 3's ProviderException wrapper
This commit is contained in:
@@ -14,7 +14,19 @@ void main() {
|
|||||||
test('audioHandlerProvider must be overridden — bare read throws', () {
|
test('audioHandlerProvider must be overridden — bare read throws', () {
|
||||||
final container = ProviderContainer();
|
final container = ProviderContainer();
|
||||||
addTearDown(container.dispose);
|
addTearDown(container.dispose);
|
||||||
expect(() => container.read(audioHandlerProvider), throwsA(isA<UnimplementedError>()));
|
// Riverpod 3 wraps the underlying error in a ProviderException. The
|
||||||
|
// intent of the test is "bare read fails," so accept the wrapper as
|
||||||
|
// long as the inner error is the UnimplementedError we threw.
|
||||||
|
expect(
|
||||||
|
() => container.read(audioHandlerProvider),
|
||||||
|
throwsA(predicate((e) {
|
||||||
|
if (e is UnimplementedError) return true;
|
||||||
|
// ProviderException is private to riverpod; match by name + by
|
||||||
|
// walking its toString for the inner UnimplementedError text.
|
||||||
|
return e.runtimeType.toString().contains('ProviderException') &&
|
||||||
|
e.toString().contains('UnimplementedError');
|
||||||
|
})),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('overridden audioHandlerProvider exposes playbackState stream', () {
|
test('overridden audioHandlerProvider exposes playbackState stream', () {
|
||||||
|
|||||||
Reference in New Issue
Block a user