Skip to content

Commit 5727ef1

Browse files
committed
test fixture
1 parent 20af837 commit 5727ef1

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

dart/test/sentry_attachment_test.dart

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,22 @@ void main() {
5151
});
5252

5353
group('$Scope $SentryAttachment tests', () {
54+
late Fixture fixture;
55+
56+
setUp(() {
57+
fixture = Fixture();
58+
});
59+
5460
test('Sending with attachments', () async {
55-
final options = SentryOptions(dsn: fakeDsn);
56-
final transport = MockTransport();
57-
options.transport = transport;
58-
final hub = Hub(options);
59-
await hub.captureEvent(SentryEvent(), withScope: (scope) {
61+
final sut = fixture.getSut();
62+
await sut.captureEvent(SentryEvent(), withScope: (scope) {
6063
scope.addAttachment(
6164
SentryAttachment.fromIntList([0, 0, 0, 0], 'test.txt'),
6265
);
6366
});
64-
expect(transport.envelopes.length, 1);
65-
expect(transport.envelopes.first.items.length, 2);
66-
final attachmentEnvelope = transport.envelopes.first.items[1];
67+
expect(fixture.transport.envelopes.length, 1);
68+
expect(fixture.transport.envelopes.first.items.length, 2);
69+
final attachmentEnvelope = fixture.transport.envelopes.first.items[1];
6770
expect(
6871
attachmentEnvelope.header.attachmentType,
6972
SentryAttachment.typeAttachmentDefault,
@@ -83,3 +86,13 @@ void main() {
8386
});
8487
});
8588
}
89+
90+
class Fixture {
91+
MockTransport transport = MockTransport();
92+
93+
Hub getSut() {
94+
final options = SentryOptions(dsn: fakeDsn);
95+
options.transport = transport;
96+
return Hub(options);
97+
}
98+
}

0 commit comments

Comments
 (0)