Skip to content

Commit 6c7212b

Browse files
committed
fixing tests
1 parent 5137d58 commit 6c7212b

File tree

4 files changed

+36
-30
lines changed

4 files changed

+36
-30
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
run: dart analyze
2525

2626
- name: Run tests
27-
run: dart test
27+
run: flutter test
2828

2929
build-linux:
3030
runs-on: ubuntu-latest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
# Created by `dart pub`
33
.dart_tool/
44
.idea/
5+
6+
build/

test/sourcemaps/sourcemap_api_test.dart

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,28 @@ void main() {
1313
group('SourcemapApi', () {
1414
late MockClient mockClient;
1515
late SourcemapApi sourcemapApi;
16+
late File testFile;
1617

1718
setUp(() {
1819
mockClient = MockClient();
1920
sourcemapApi = SourcemapApi(httpClient: mockClient);
21+
// Create a temporary test file
22+
testFile = File('test_sourcemap.js.map');
23+
testFile.writeAsStringSync('{"version": 3, "sources": ["test.js"]}');
2024
});
2125

22-
group('uploadSourcemap', () {
23-
late File testFile;
24-
25-
setUpAll(() {
26-
// Create a temporary test file
27-
testFile = File('test_sourcemap.js.map');
28-
testFile.writeAsStringSync('{"version": 3, "sources": ["test.js"]}');
29-
});
30-
31-
tearDownAll(() {
32-
// Clean up the test file after all tests
33-
try {
34-
if (testFile.existsSync()) {
35-
testFile.deleteSync();
36-
}
37-
} catch (e) {
38-
// Ignore if the file cannot be deleted
26+
tearDown(() {
27+
// Clean up the test file after all tests
28+
try {
29+
if (testFile.existsSync()) {
30+
testFile.deleteSync();
3931
}
40-
});
32+
} catch (e) {
33+
// Ignore if the file cannot be deleted
34+
}
35+
});
4136

37+
group('uploadSourcemap', () {
4238
test('returns true when upload is successful (200)', () async {
4339
final response = http.StreamedResponse(
4440
Stream.value([]),
@@ -50,7 +46,7 @@ void main() {
5046
final result = await sourcemapApi.uploadSourcemap(
5147
appId: 'test-app-id',
5248
token: 'test-token',
53-
path: 'test_sourcemap.js.map',
49+
path: testFile.path,
5450
uri: 'https://example.com/app.js',
5551
);
5652

@@ -69,7 +65,7 @@ void main() {
6965
final result = await sourcemapApi.uploadSourcemap(
7066
appId: 'test-app-id',
7167
token: 'test-token',
72-
path: 'test_sourcemap.js.map',
68+
path: testFile.path,
7369
uri: 'https://example.com/app.js',
7470
);
7571

test/sourcemaps/sourcemap_command_test.dart

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,29 @@ void main() {
1212
group('SourcemapCommand', () {
1313
late MockSourcemapApi mockApi;
1414
late SourcemapCommand command;
15+
late File testFile;
1516

1617
setUp(() {
1718
mockApi = MockSourcemapApi();
1819
command = SourcemapCommand(api: mockApi);
20+
// Create a temporary test file
21+
testFile = File('test_sourcemap.js.map');
22+
testFile.writeAsStringSync('{"version": 3, "sources": ["test.js"]}');
23+
});
24+
25+
tearDown(() {
26+
// Clean up the test file after all tests
27+
try {
28+
if (testFile.existsSync()) {
29+
testFile.deleteSync();
30+
}
31+
} catch (e) {
32+
// Ignore if the file cannot be deleted
33+
}
1934
});
2035

2136
group('run', () {
2237
test('handles single file upload (platform null)', () async {
23-
// Create a temporary test file
24-
final testFile = File('test_sourcemap.js.map');
25-
testFile.writeAsStringSync('{"version": 3, "sources": ["test.js"]}');
26-
2738
when(mockApi.uploadSourcemap(
2839
appId: anyNamed('appId'),
2940
token: anyNamed('token'),
@@ -39,7 +50,7 @@ void main() {
3950
'--app-id=test-app-id',
4051
'--token=test-token',
4152
'--uri=http://test.com/app.js',
42-
'--input-map=test_sourcemap.js.map'
53+
'--input-map=${testFile.path}',
4354
]);
4455

4556
final result = await command.run(
@@ -51,12 +62,9 @@ void main() {
5162
verify(mockApi.uploadSourcemap(
5263
appId: 'test-app-id',
5364
token: 'test-token',
54-
path: 'test_sourcemap.js.map',
65+
path: testFile.path,
5566
uri: 'http://test.com/app.js',
5667
)).called(1);
57-
58-
// Clean up
59-
testFile.deleteSync();
6068
});
6169

6270
test('handles flutter platform upload', () async {

0 commit comments

Comments
 (0)