Skip to content

Commit

Permalink
Add regression test for #2617
Browse files Browse the repository at this point in the history
fixes #2617
  • Loading branch information
rrousselGit committed Oct 3, 2023
1 parent 6e8afae commit 2ac05f0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/riverpod/test/providers/notifier/notifier_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@ import 'factory.dart';
void main() {
for (final factory in matrix()) {
group(factory.label, () {
test(
'throws if the same Notifier instance is reused in different providers',
() {
// Regression test for https://github.com/rrousselGit/riverpod/issues/2617
final container = createContainer();

final notifier = factory.notifier((ref) => 0);

final provider = factory.provider<TestNotifierBase<int>, int>(
() => notifier,
);
final provider2 = factory.provider<TestNotifierBase<int>, int>(
() => notifier,
);

container.read(provider);

expect(
() => container.read(provider2),
throwsA(isA<Error>()),
);
});

group('Notifier.stateOrNull', () {
test('returns null during first build until state= is set', () {
final stateInBuild = <int?>[];
Expand Down

0 comments on commit 2ac05f0

Please sign in to comment.