55// Tests for ROHD Bridge Logger functionality.
66
77import 'dart:io' ;
8- import 'package:test/test.dart' ;
9- import 'package:logging/logging.dart' ;
8+
109import 'package:rohd_bridge/src/rohd_bridge_logger.dart' ;
10+ import 'package:test/test.dart' ;
1111
1212void main () {
1313 group ('RohdBridgeLogger' , () {
@@ -28,35 +28,38 @@ void main() {
2828 final logFile1 = '${tempDir .path }/test1.log' ;
2929 final logFile2 = '${tempDir .path }/test2.log' ;
3030
31+ const firstConfigurationMessage = 'First configuration' ;
32+ const secondConfigurationMessage = 'Second configuration' ;
33+
3134 // Configure logger first time
3235 RohdBridgeLogger .configureLogger (logFile1);
3336
3437 // Log a message
35- RohdBridgeLogger .logger.info ('First configuration' );
38+ RohdBridgeLogger .logger.info (firstConfigurationMessage );
3639 await RohdBridgeLogger .flush ();
3740
3841 // Reconfigure logger - this should clean up previous subscriptions
3942 RohdBridgeLogger .configureLogger (logFile2);
4043
4144 // Log another message after reconfiguration
42- RohdBridgeLogger .logger.info ('Second configuration' );
45+ RohdBridgeLogger .logger.info (secondConfigurationMessage );
4346 await RohdBridgeLogger .flush ();
4447
4548 // Verify first log file exists and has content from first configuration
4649 expect (File (logFile1).existsSync (), isTrue);
4750 final firstLogContent = await File (logFile1).readAsString ();
48- expect (firstLogContent, contains ('First configuration' ));
51+ expect (firstLogContent, contains (firstConfigurationMessage ));
4952
5053 // Verify second log file exists and has content from second configuration
5154 expect (File (logFile2).existsSync (), isTrue);
5255 final secondLogContent = await File (logFile2).readAsString ();
53- expect (secondLogContent, contains ('Second configuration' ));
56+ expect (secondLogContent, contains (secondConfigurationMessage ));
5457
5558 // Second log should not contain first message (proves no duplicate logging)
56- expect (secondLogContent, isNot (contains ('First configuration' )));
59+ expect (secondLogContent, isNot (contains (firstConfigurationMessage )));
5760
5861 // First log should not contain second message (proves cleanup worked)
59- expect (firstLogContent, isNot (contains ('Second configuration' )));
62+ expect (firstLogContent, isNot (contains (secondConfigurationMessage )));
6063 });
6164
6265 test ('configureLogger handles null fileSink gracefully' , () {
@@ -71,7 +74,7 @@ void main() {
7174 final logFiles = < String > [];
7275
7376 // Configure logger multiple times
74- for (int i = 0 ; i < 3 ; i++ ) {
77+ for (var i = 0 ; i < 3 ; i++ ) {
7578 final logFile = '${tempDir .path }/test$i .log' ;
7679 logFiles.add (logFile);
7780
@@ -81,13 +84,13 @@ void main() {
8184 }
8285
8386 // Each log file should exist and contain only its respective message
84- for (int i = 0 ; i < 3 ; i++ ) {
87+ for (var i = 0 ; i < 3 ; i++ ) {
8588 expect (File (logFiles[i]).existsSync (), isTrue);
8689 final content = await File (logFiles[i]).readAsString ();
8790 expect (content, contains ('Message $i ' ));
8891
8992 // Should not contain messages from other configurations
90- for (int j = 0 ; j < 3 ; j++ ) {
93+ for (var j = 0 ; j < 3 ; j++ ) {
9194 if (i != j) {
9295 expect (content, isNot (contains ('Message $j ' )));
9396 }
0 commit comments