-
-
Notifications
You must be signed in to change notification settings - Fork 257
Fix: Use App Name if Package Name is not available #411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
66d795c
Fix: Use App Name if Package Name is not available
ueman 42260a7
add comment describing the code
ueman f235de2
replace invalid chars with underscore
ueman 6567afd
Formatting
ueman 7ffd05f
Improve comment
ueman 04c6e87
Add PR ID to changelog
ueman f6631eb
Use TestFixture
ueman 97e1e34
improve test fixture
ueman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -227,35 +227,61 @@ void main() { | |
}); | ||
|
||
group('$LoadReleaseIntegration', () { | ||
Future<PackageInfo> loadRelease() { | ||
return Future.value(PackageInfo( | ||
appName: 'sentry_flutter', | ||
packageName: 'foo.bar', | ||
version: '1.2.3', | ||
buildNumber: '789', | ||
)); | ||
} | ||
late LoadReleaseIntegrationFixture fixture; | ||
|
||
setUp(() { | ||
fixture = LoadReleaseIntegrationFixture(); | ||
}); | ||
|
||
test('does not overwrite options', () async { | ||
final options = SentryFlutterOptions(dsn: fakeDsn); | ||
options.release = '1.0.0'; | ||
options.dist = 'dist'; | ||
fixture.options.release = '1.0.0'; | ||
fixture.options.dist = 'dist'; | ||
|
||
final integration = LoadReleaseIntegration(loadRelease); | ||
await integration.call(MockHub(), options); | ||
await fixture.getIntegration().call(MockHub(), fixture.options); | ||
|
||
expect(options.release, '1.0.0'); | ||
expect(options.dist, 'dist'); | ||
expect(fixture.options.release, '1.0.0'); | ||
expect(fixture.options.dist, 'dist'); | ||
}); | ||
|
||
test('sets release and dist if not set on options', () async { | ||
final options = SentryFlutterOptions(dsn: fakeDsn); | ||
await fixture.getIntegration().call(MockHub(), fixture.options); | ||
|
||
expect(fixture.options.release, '[email protected]+789'); | ||
expect(fixture.options.dist, '789'); | ||
}); | ||
|
||
final integration = LoadReleaseIntegration(loadRelease); | ||
await integration.call(MockHub(), options); | ||
test('sets app name as in release if packagename is empty', () async { | ||
final loader = () { | ||
return Future.value(PackageInfo( | ||
appName: 'sentry_flutter', | ||
packageName: '', | ||
version: '1.2.3', | ||
buildNumber: '789', | ||
)); | ||
}; | ||
await fixture | ||
.getIntegration(loader: loader) | ||
.call(MockHub(), fixture.options); | ||
|
||
expect(fixture.options.release, '[email protected]+789'); | ||
expect(fixture.options.dist, '789'); | ||
}); | ||
|
||
expect(options.release, '[email protected]+789'); | ||
expect(options.dist, '789'); | ||
test('release name does not contain ivalid chars', () async { | ||
final loader = () { | ||
return Future.value(PackageInfo( | ||
appName: '\\/sentry\tflutter \r\nfoo\nbar\r', | ||
packageName: '', | ||
version: '1.2.3', | ||
buildNumber: '789', | ||
)); | ||
}; | ||
await fixture | ||
.getIntegration(loader: loader) | ||
.call(MockHub(), fixture.options); | ||
|
||
expect(fixture.options.release, '__sentry_flutter [email protected]+789'); | ||
expect(fixture.options.dist, '789'); | ||
}); | ||
}); | ||
} | ||
|
@@ -264,3 +290,21 @@ class Fixture { | |
final hub = MockHub(); | ||
final options = SentryFlutterOptions(); | ||
} | ||
|
||
class LoadReleaseIntegrationFixture { | ||
final hub = MockHub(); | ||
final options = SentryFlutterOptions(dsn: fakeDsn); | ||
|
||
LoadReleaseIntegration getIntegration({PackageLoader? loader}) { | ||
return LoadReleaseIntegration(loader ?? loadRelease); | ||
} | ||
|
||
Future<PackageInfo> loadRelease() { | ||
return Future.value(PackageInfo( | ||
appName: 'sentry_flutter', | ||
packageName: 'foo.bar', | ||
version: '1.2.3', | ||
buildNumber: '789', | ||
)); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.