fix: correct test failures and error propagation

- Add CacheScope provider in UserProfileCacheRepository tests
- Remove catch blocks that swallowed errors in _loadHistory/_loadMoreHistory
- Errors now properly propagate to switchUser() caller
This commit is contained in:
qzl
2026-04-01 15:11:49 +08:00
parent 640b4d15a3
commit 19aa33a609
9 changed files with 7 additions and 48 deletions
@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:flutter_test/flutter_test.dart';
import 'package:social_app/data/cache/cache_scope.dart';
import 'package:social_app/data/cache/cache_store.dart';
import 'package:social_app/features/contacts/data/models/user_profile.dart';
import 'package:social_app/features/settings/data/repositories/user_profile_cache_repository.dart';
@@ -8,6 +9,8 @@ import 'package:social_app/features/settings/data/repositories/user_profile_cach
void main() {
group('UserProfileCacheRepository', () {
test('keeps in-memory snapshot and invalidates correctly', () async {
CacheScope.configureProvider(() => 'test-scope');
addTearDown(() => CacheScope.resetProvider());
var remoteCalls = 0;
final repository = UserProfileCacheRepository(
store: HybridCacheStore(
@@ -40,6 +43,9 @@ void main() {
test(
'invalidate prevents stale in-flight refresh from restoring cache',
() async {
CacheScope.configureProvider(() => 'test-scope-2');
addTearDown(() => CacheScope.resetProvider());
final completer = Completer<UserProfile>();
final repository = UserProfileCacheRepository(
store: HybridCacheStore(