Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
buenaflor committed Jan 23, 2024
1 parent 8b7c65b commit 23a8208
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
10 changes: 2 additions & 8 deletions lib/src/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,8 @@ class Configuration {
Log.startingTask(taskName);
await _findAndSetCliPath();

try {
final reader = ConfigReader();
loadConfig(reader);
} catch (e) {
// Will catch an exception if no proper config could be found e.g sentry.properties or pubspec.yaml
Log.error(e.toString());
return;
}
final reader = ConfigReader();
loadConfig(reader);

Log.taskCompleted(taskName);
}
Expand Down
5 changes: 3 additions & 2 deletions lib/src/utils/config-reader/config_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:file/file.dart';

import '../injector.dart';
import '../log.dart';
import 'no_op_config_reader.dart';
import 'properties_config_reader.dart';
import 'yaml_config_reader.dart';

Expand Down Expand Up @@ -35,8 +36,8 @@ abstract class ConfigReader {
Properties.fromString(propertiesFile.readAsStringSync());
return PropertiesConfigReader(properties);
}
throw Exception(
'no config found, please use sentry.properties or pubspec.yaml.');
Log.error('no config found, please use sentry.properties or pubspec.yaml.');
return NoOpConfigReader();
}

static dynamic getPubspec() {
Expand Down
20 changes: 20 additions & 0 deletions lib/src/utils/config-reader/no_op_config_reader.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'config_reader.dart';

class NoOpConfigReader implements ConfigReader {
NoOpConfigReader();

@override
bool? getBool(String key, {String? deprecatedKey}) {
return null;
}

@override
String? getString(String key, {String? deprecatedKey}) {
return null;
}

@override
bool contains(String key) {
return false;
}
}

0 comments on commit 23a8208

Please sign in to comment.