Skip to content

Commit c75f3d5

Browse files
committed
fix: tests
1 parent 617eaf9 commit c75f3d5

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

test/sourcemaps/sourcemap_api_test.dart

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,27 @@ void main() {
2020
});
2121

2222
group('uploadSourcemap', () {
23-
test('returns true when upload is successful (200)', () async {
23+
24+
late File testFile;
25+
26+
setUpAll(() {
2427
// Create a temporary test file
25-
final testFile = File('test_sourcemap.js.map');
28+
testFile = File('test_sourcemap.js.map');
2629
testFile.writeAsStringSync('{"version": 3, "sources": ["test.js"]}');
30+
});
31+
32+
tearDownAll(() {
33+
// Clean up the test file after all tests
34+
try {
35+
if (testFile.existsSync()) {
36+
testFile.deleteSync();
37+
}
38+
} catch (e) {
39+
// Ignore if the file cannot be deleted
40+
}
41+
});
2742

43+
test('returns true when upload is successful (200)', () async {
2844
final response = http.StreamedResponse(
2945
Stream.value([]),
3046
200,
@@ -41,15 +57,9 @@ void main() {
4157

4258
expect(result, true);
4359
verify(mockClient.send(any)).called(1);
44-
45-
// Clean up
46-
testFile.deleteSync();
4760
});
4861

4962
test('returns false when upload fails', () async {
50-
final testFile = File('test_sourcemap.js.map');
51-
testFile.writeAsStringSync('{"version": 3, "sources": ["test.js"]}');
52-
5363
final response = http.StreamedResponse(
5464
Stream.value([]),
5565
400,
@@ -65,8 +75,6 @@ void main() {
6575
);
6676

6777
expect(result, false);
68-
69-
testFile.deleteSync();
7078
});
7179

7280
test('returns false when file does not exist', () async {

0 commit comments

Comments
 (0)