Skip to content

Commit

Permalink
Fix reuse error
Browse files Browse the repository at this point in the history
refs #5
  • Loading branch information
brolandeau committed Jan 6, 2025
1 parent acc2645 commit a1ed385
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 1 deletion.
16 changes: 16 additions & 0 deletions bro_config_manager/test/mock/models/a_model.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
// SPDX-FileCopyrightText: 2024 Benoit Rolandeau <[email protected]>
//
// SPDX-License-Identifier: MIT

import 'package:equatable/equatable.dart';

/// A simple model with a name and an age to be parsed as config
class AModel extends Equatable {
/// The key for the name in the json
static const nameKey = 'name';

/// The key for the age in the json
static const ageKey = 'age';

/// The name of the model
final String name;

/// The age of the model
final int age;

/// Creates a new AModel
const AModel({
required this.name,
required this.age,
});

/// Creates a new AModel from a json
// The type is dynamic because we can parse the model from a json object or array
// ignore: avoid_annotating_with_dynamic
static AModel? fromJson(dynamic json) {
if (json is! Map<String, dynamic>) {
return null;
Expand All @@ -30,6 +45,7 @@ class AModel extends Equatable {
);
}

/// Model properties
@override
List<Object?> get props => [name, age];
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// SPDX-FileCopyrightText: 2024 Benoit Rolandeau <[email protected]>
//
// SPDX-License-Identifier: MIT

/// Error thrown when the global manager was not created and we try to access it.
class GlobalManagerNotCreatedError extends Error {
/// Returns a string representation of this error.
@override
String toString() => "The global manager was not created.";
}
4 changes: 4 additions & 0 deletions bro_logger_manager/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024 Benoit Rolandeau <[email protected]>
#
# SPDX-License-Identifier: MIT

# Miscellaneous
*.class
*.log
Expand Down
1 change: 1 addition & 0 deletions bro_logger_manager/test/logger_manager_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_test/flutter_test.dart';

import 'mock/services/global_manager.dart';

/// Test the logger manager
void main() {
test('Test logger manager print to console', () async {
await GlobalManager.instance.initLifeCycle();
Expand Down
6 changes: 5 additions & 1 deletion bro_logger_manager/test/mock/services/config_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ import 'package:bro_config_manager/bro_config_manager.dart';
import 'package:bro_global_manager/bro_global_manager.dart';
import 'package:bro_logger_manager/bro_logger_manager.dart';

///
/// Create a builder for the [ConfigManager]
class ConfigManagerBuilder extends AbsManagerBuilder<ConfigManager> {
/// Create a builder for the [ConfigManager]
ConfigManagerBuilder() : super(ConfigManager.new);

/// {@macro bro_abstract_manager.AbsManagerBuilder.getDependencies}
@override
Iterable<Type> getDependencies() => [];
}

/// This is the config manager to use for the tests.
class ConfigManager extends AbstractConfigManager with MixinLoggerConfigs {
/// {@macro bro_config_manager.AbstractConfigManager.getInitConfigManagerModel}
@override
Future<InitConfigManagerModel> getInitConfigManagerModel() async => const InitConfigManagerModel(
configFolderPath: "test/assets/config",
Expand Down
5 changes: 5 additions & 0 deletions bro_logger_manager/test/mock/services/global_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ import 'package:bro_logger_manager/bro_logger_manager.dart';

import 'config_manager.dart';

/// This is the global manager to use for the tests.
class GlobalManager extends AbsGlobalManager {
/// Get the instance of the global manager.
///
/// Create the instance if it does not exist.
static GlobalManager get instance => AbsGlobalManager.getCastedInstance(GlobalManager.new);

/// {@macro abs_global_manager.AbsGlobalManager.registerManagers}
@override
void registerManagers(
void Function<M extends AbsWithLifeCycle, B extends AbsManagerBuilder<M>>(B builder)
Expand Down

0 comments on commit a1ed385

Please sign in to comment.