-
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/always-send-sampled-flag
- Loading branch information
Showing
24 changed files
with
155 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import 'package:sentry/sentry.dart'; | ||
import 'package:sentry/src/diagnostic_logger.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
late Fixture fixture; | ||
|
||
setUp(() { | ||
fixture = Fixture(); | ||
}); | ||
|
||
test('$DiagnosticLogger do not log if debug is disabled', () { | ||
fixture.options.debug = false; | ||
|
||
fixture.getSut().log(SentryLevel.error, 'foobar'); | ||
|
||
expect(fixture.loggedMessage, isNull); | ||
}); | ||
|
||
test('$DiagnosticLogger log if debug is enabled', () { | ||
fixture.options.debug = true; | ||
|
||
fixture.getSut().log(SentryLevel.error, 'foobar'); | ||
|
||
expect(fixture.loggedMessage, 'foobar'); | ||
}); | ||
|
||
test('$DiagnosticLogger do not log if level is too low', () { | ||
fixture.options.debug = true; | ||
fixture.options.diagnosticLevel = SentryLevel.error; | ||
|
||
fixture.getSut().log(SentryLevel.warning, 'foobar'); | ||
|
||
expect(fixture.loggedMessage, isNull); | ||
}); | ||
|
||
test('$DiagnosticLogger always log fatal', () { | ||
fixture.options.debug = false; | ||
|
||
fixture.getSut().log(SentryLevel.fatal, 'foobar'); | ||
|
||
expect(fixture.loggedMessage, 'foobar'); | ||
}); | ||
} | ||
|
||
class Fixture { | ||
var options = SentryOptions(); | ||
|
||
Object? loggedMessage; | ||
|
||
DiagnosticLogger getSut() { | ||
return DiagnosticLogger(mockLogger, options); | ||
} | ||
|
||
void mockLogger( | ||
SentryLevel level, | ||
String message, { | ||
String? logger, | ||
Object? exception, | ||
StackTrace? stackTrace, | ||
}) { | ||
loggedMessage = message; | ||
} | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
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
Oops, something went wrong.