From 296bb0175ef3ebf86eae08efd916e5fc23e17213 Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Mon, 15 May 2023 16:15:42 +0200 Subject: [PATCH] feat(auth): add mocked cache data source --- ...ntication_mock_cache_data_source_impl.dart | 41 +++++++++++++++++++ .../src/data/data_sources/local/local.dart | 1 + 2 files changed, 42 insertions(+) create mode 100644 packages/wyatt_authentication_bloc/lib/src/data/data_sources/local/authentication_mock_cache_data_source_impl.dart diff --git a/packages/wyatt_authentication_bloc/lib/src/data/data_sources/local/authentication_mock_cache_data_source_impl.dart b/packages/wyatt_authentication_bloc/lib/src/data/data_sources/local/authentication_mock_cache_data_source_impl.dart new file mode 100644 index 00000000..3c23a866 --- /dev/null +++ b/packages/wyatt_authentication_bloc/lib/src/data/data_sources/local/authentication_mock_cache_data_source_impl.dart @@ -0,0 +1,41 @@ +// Copyright (C) 2023 WYATT GROUP +// Please see the AUTHORS file for details. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart'; + +/// {@template authentication_mock_cache_data_source_impl} +/// A data source that manages the cache strategy. +/// This implementation is mocked. +/// {@endtemplate} +class AuthenticationMockCacheDataSourceImpl + extends AuthenticationCacheDataSource { + /// {@macro authentication_mock_cache_data_source_impl} + AuthenticationMockCacheDataSourceImpl(); + + @override + Future cacheAccount(Account account) => Future.value(); + + /// Always returns null. + @override + Future getCachedAccount() async { + await Future.delayed(const Duration(milliseconds: 200)); + +return null; + } + + @override + Future removeCachedAccount() => Future.value(); +} diff --git a/packages/wyatt_authentication_bloc/lib/src/data/data_sources/local/local.dart b/packages/wyatt_authentication_bloc/lib/src/data/data_sources/local/local.dart index b9bf04e1..53cb73e5 100644 --- a/packages/wyatt_authentication_bloc/lib/src/data/data_sources/local/local.dart +++ b/packages/wyatt_authentication_bloc/lib/src/data/data_sources/local/local.dart @@ -15,5 +15,6 @@ // along with this program. If not, see . export 'authentication_firebase_cache_data_source_impl.dart'; +export 'authentication_mock_cache_data_source_impl.dart'; export 'authentication_secure_storage_cache_data_source_impl.dart'; export 'authentication_session_data_source_impl.dart';