@@ -550,6 +550,45 @@ void main() {
550550 );
551551 });
552552
553+ test ('setAttributes sets attributes on scope' , () {
554+ hub.setAttributes ({
555+ 'attr1' : SentryAttribute .string ('value' ),
556+ 'attr2' : SentryAttribute .int (42 ),
557+ 'attr3' : SentryAttribute .bool (true ),
558+ 'attr4' : SentryAttribute .double (3.14 )
559+ });
560+ hub.setAttributes ({'merged' : SentryAttribute .double (12 )});
561+
562+ final attributes = hub.scope.attributes;
563+ expect (attributes, isNotEmpty);
564+ expect (attributes['attr1' ]? .value, SentryAttribute .string ('value' ).value);
565+ expect (attributes['attr2' ]? .value, SentryAttribute .int (42 ).value);
566+ expect (attributes['attr3' ]? .value, SentryAttribute .bool (true ).value);
567+ expect (attributes['attr4' ]? .value, SentryAttribute .double (3.14 ).value);
568+ expect (attributes['merged' ]? .value, SentryAttribute .double (12 ).value);
569+ });
570+
571+ test ('removeAttribute removes attribute on scope' , () {
572+ hub.setAttributes ({
573+ 'attr1' : SentryAttribute .string ('value' ),
574+ 'attr2' : SentryAttribute .int (42 ),
575+ 'attr3' : SentryAttribute .bool (true ),
576+ 'attr4' : SentryAttribute .double (3.14 )
577+ });
578+ hub.setAttributes ({'merged' : SentryAttribute .double (12 )});
579+
580+ hub.removeAttribute ('attr3' );
581+ hub.removeAttribute ('merged' );
582+
583+ final attributes = hub.scope.attributes;
584+ expect (attributes, isNotEmpty);
585+ expect (attributes['attr1' ]? .value, SentryAttribute .string ('value' ).value);
586+ expect (attributes['attr2' ]? .value, SentryAttribute .int (42 ).value);
587+ expect (attributes['attr4' ]? .value, SentryAttribute .double (3.14 ).value);
588+ expect (attributes['attr3' ]? .value, isNull);
589+ expect (attributes['merged' ]? .value, isNull);
590+ });
591+
553592 test ('should configure scope async' , () async {
554593 await hub.configureScope ((Scope scope) async {
555594 await Future .delayed (Duration (milliseconds: 10 ));
0 commit comments