Skip to content

Commit

Permalink
GS-9879 Fix force update bug (#2232)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Pasc <[email protected]>
Co-authored-by: Paul Pasc <[email protected]>
  • Loading branch information
3 people authored and github-actions[bot] committed Aug 8, 2023
1 parent 7416515 commit 53ed425
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ void _configureUseCases() {

getIt
..registerFactory<ShouldShowForceUpdateUseCase>(
() => ShouldShowForceUpdateUseCase(getIt(), getIt()),
() => ShouldShowForceUpdateUseCase(
getIt(),
getIt(),
getIt(),
),
)

//DO-NOT-REMOVE USE_CASES_GET_IT_CONFIG
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import 'package:picnic_app/core/domain/stores/app_info_store.dart';
import 'package:picnic_app/core/domain/use_cases/set_app_info_use_case.dart';
import 'package:picnic_app/core/utils/either_extensions.dart';
import 'package:picnic_app/features/force_update/domain/use_case/fetch_min_app_version_use_case.dart';

class ShouldShowForceUpdateUseCase {
const ShouldShowForceUpdateUseCase(
this._fetchMinAppVersionUseCase,
this._appInfoStore,
this._setAppInfoUseCase,
);

final FetchMinAppVersionUseCase _fetchMinAppVersionUseCase;
final AppInfoStore _appInfoStore;
final SetAppInfoUseCase _setAppInfoUseCase;

Future<bool> execute() async {
final remoteAppVersion = await _getRemoteAppVersion();
await _setAppInfoUseCase.execute();
final appVersion = _appInfoStore.appInfo.appVersion;

if (remoteAppVersion.isEmpty || appVersion.isEmpty) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:dartz/dartz.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:picnic_app/dependency_injection/app_component.dart';
Expand All @@ -14,10 +15,12 @@ void main() {

setUp(() {
when(() => Mocks.appInfoStore.appInfo).thenReturn(Stubs.appInfo);
when(() => Mocks.setAppInfoUseCase.execute()).thenAnswer((_) => successFuture(unit));

useCase = ShouldShowForceUpdateUseCase(
ForceUpdateMocks.getMinAppVersionUseCase,
Mocks.appInfoStore,
Mocks.setAppInfoUseCase,
);
});

Expand Down

0 comments on commit 53ed425

Please sign in to comment.