forked from serverpod/serverpod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Pass string instead of error object to logger in
session.close
. (
- Loading branch information
1 parent
aefba28
commit 732ccfb
Showing
8 changed files
with
86 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
tests/serverpod_test_server/test_integration/logging/session_close_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:serverpod/serverpod.dart'; | ||
import 'package:serverpod_test_server/test_util/mock_stdout.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../test_tools/serverpod_test_tools.dart'; | ||
|
||
class TestError extends Error { | ||
@override | ||
String toString() { | ||
return 'TestError'; | ||
} | ||
} | ||
|
||
void main() { | ||
withServerpod( | ||
'Given an existing session with session logging disabled', | ||
enableSessionLogging: false, | ||
serverpodLoggingMode: ServerpodLoggingMode.verbose, | ||
(sessionBuilder, endpoints) { | ||
late MockStdout record; | ||
|
||
setUp(() async { | ||
record = MockStdout(); | ||
}); | ||
|
||
test( | ||
'when closing session with error, the error should be logged and the session should be closed', | ||
() async { | ||
await IOOverrides.runZoned( | ||
() async { | ||
await sessionBuilder.build().close(error: TestError()); | ||
}, | ||
stdout: () => record, | ||
); | ||
|
||
expect(record.output, contains('TestError')); | ||
}); | ||
|
||
test( | ||
'when closing session with error and stackTrace, the error should be logged and the session should be closed', | ||
() async { | ||
await IOOverrides.runZoned( | ||
() async { | ||
await sessionBuilder.build().close( | ||
error: TestError(), | ||
stackTrace: StackTrace.fromString('TestStackTrace')); | ||
}, | ||
stdout: () => record, | ||
); | ||
|
||
expect(record.output, contains('TestError')); | ||
expect(record.output, contains('TestStackTrace')); | ||
}); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters