@@ -227,40 +227,79 @@ void main() {
227
227
});
228
228
229
229
group ('$LoadReleaseIntegration ' , () {
230
- Future <PackageInfo > loadRelease () {
231
- return Future .value (PackageInfo (
232
- appName: 'sentry_flutter' ,
233
- packageName: 'foo.bar' ,
234
- version: '1.2.3' ,
235
- buildNumber: '789' ,
236
- ));
237
- }
230
+ late Fixture fixture;
231
+
232
+ setUp (() {
233
+ fixture = Fixture ();
234
+ });
238
235
239
236
test ('does not overwrite options' , () async {
240
- final options = SentryFlutterOptions (dsn: fakeDsn);
241
- options.release = '1.0.0' ;
242
- options.dist = 'dist' ;
237
+ fixture.options.release = '1.0.0' ;
238
+ fixture.options.dist = 'dist' ;
243
239
244
- final integration = LoadReleaseIntegration (loadRelease);
245
- await integration.call (MockHub (), options);
240
+ await fixture.getIntegration ().call (MockHub (), fixture.options);
246
241
247
- expect (options.release, '1.0.0' );
248
- expect (options.dist, 'dist' );
242
+ expect (fixture. options.release, '1.0.0' );
243
+ expect (fixture. options.dist, 'dist' );
249
244
});
250
245
251
246
test ('sets release and dist if not set on options' , () async {
252
- final options = SentryFlutterOptions (dsn : fakeDsn );
247
+ await fixture. getIntegration (). call ( MockHub (), fixture.options );
253
248
254
- final integration = LoadReleaseIntegration (loadRelease);
255
- await integration.call (MockHub (), options);
249
+ expect (fixture.options.release,
'[email protected] +789' );
250
+ expect (fixture.options.dist, '789' );
251
+ });
252
+
253
+ test ('sets app name as in release if packagename is empty' , () async {
254
+ final loader = () {
255
+ return Future .value (PackageInfo (
256
+ appName: 'sentry_flutter' ,
257
+ packageName: '' ,
258
+ version: '1.2.3' ,
259
+ buildNumber: '789' ,
260
+ ));
261
+ };
262
+ await fixture
263
+ .getIntegration (loader: loader)
264
+ .call (MockHub (), fixture.options);
265
+
266
+ expect (fixture.options.release,
'[email protected] +789' );
267
+ expect (fixture.options.dist, '789' );
268
+ });
256
269
257
- expect (options.release,
'[email protected] +789' );
258
- expect (options.dist, '789' );
270
+ test ('release name does not contain ivalid chars' , () async {
271
+ final loader = () {
272
+ return Future .value (PackageInfo (
273
+ appName: '\\ /sentry\t flutter \r\n foo\n bar\r ' ,
274
+ packageName: '' ,
275
+ version: '1.2.3' ,
276
+ buildNumber: '789' ,
277
+ ));
278
+ };
279
+ await fixture
280
+ .getIntegration (loader: loader)
281
+ .call (MockHub (), fixture.options);
282
+
283
+ expect (fixture.options.release,
'__sentry_flutter [email protected] +789' );
284
+ expect (fixture.options.dist, '789' );
259
285
});
260
286
});
261
287
}
262
288
263
289
class Fixture {
264
290
final hub = MockHub ();
265
- final options = SentryFlutterOptions ();
291
+ final options = SentryFlutterOptions (dsn: fakeDsn);
292
+
293
+ LoadReleaseIntegration getIntegration ({PackageLoader ? loader}) {
294
+ return LoadReleaseIntegration (loader ?? loadRelease);
295
+ }
296
+
297
+ Future <PackageInfo > loadRelease () {
298
+ return Future .value (PackageInfo (
299
+ appName: 'sentry_flutter' ,
300
+ packageName: 'foo.bar' ,
301
+ version: '1.2.3' ,
302
+ buildNumber: '789' ,
303
+ ));
304
+ }
266
305
}
0 commit comments