Skip to content

Commit b3e16e8

Browse files
committed
Added FileOutput test
1 parent 271c3e9 commit b3e16e8

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/outputs/file_output_test.dart

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import 'dart:io';
2+
3+
import 'package:logger/logger.dart';
4+
import 'package:test/test.dart';
5+
6+
void main() {
7+
var file = File("${Directory.systemTemp.path}/dart_logger_test.log");
8+
setUp(() async {
9+
await file.create(recursive: true);
10+
});
11+
12+
tearDown(() async {
13+
await file.delete();
14+
});
15+
16+
test('Real file read and write', () async {
17+
var output = FileOutput(file: file);
18+
await output.init();
19+
20+
final event0 = OutputEvent(LogEvent(Level.info, null), ["First event"]);
21+
final event1 = OutputEvent(LogEvent(Level.info, null), ["Second event"]);
22+
final event2 = OutputEvent(LogEvent(Level.info, null), ["Third event"]);
23+
24+
output.output(event0);
25+
output.output(event1);
26+
output.output(event2);
27+
28+
await output.destroy();
29+
30+
var content = await file.readAsString();
31+
expect(
32+
content,
33+
allOf(
34+
contains("First event"),
35+
contains("Second event"),
36+
contains("Third event"),
37+
),
38+
);
39+
});
40+
}

0 commit comments

Comments
 (0)