Make coverage visible again

This commit is contained in:
Christian Pauly 2020-05-19 09:28:13 +00:00
parent 359e03496a
commit 066221b84d
9 changed files with 77 additions and 41 deletions

3
.gitignore vendored
View file

@ -9,6 +9,9 @@
.history .history
.svn/ .svn/
native/ native/
test/.test_coverage.dart
coverage/
coverage_badge.svg
# IntelliJ related # IntelliJ related
*.iml *.iml

View file

@ -8,7 +8,6 @@ coverage:
- linux - linux
stage: coverage stage: coverage
image: debian:testing image: debian:testing
coverage: '/^\s+lines.+: (\d+.\d*%)/'
dependencies: [] dependencies: []
script: script:
- apt update - apt update
@ -24,6 +23,10 @@ coverage:
- chmod +x ./test.sh - chmod +x ./test.sh
- su -c ./prepare.sh test - su -c ./prepare.sh test
- su -c ./test.sh test - su -c ./test.sh test
artifacts:
paths:
- coverage/
coverage_without_olm: coverage_without_olm:
tags: tags:

View file

@ -274,6 +274,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.1" version: "3.0.1"
lcov:
dependency: transitive
description:
name: lcov
url: "https://pub.dartlang.org"
source: hosted
version: "5.7.0"
logging: logging:
dependency: transitive dependency: transitive
description: description:
@ -586,6 +593,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.4" version: "0.3.4"
test_coverage:
dependency: "direct dev"
description:
name: test_coverage
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.1"
timing: timing:
dependency: transitive dependency: transitive
description: description:

View file

@ -29,7 +29,8 @@ dependencies:
dev_dependencies: dev_dependencies:
test: ^1.0.0 test: ^1.0.0
test_coverage: ^0.4.1
moor_generator: ^3.0.0 moor_generator: ^3.0.0
build_runner: ^1.5.2 build_runner: ^1.5.2
pedantic: ^1.9.0 # DO NOT UPDATE AS THIS WOULD CAUSE FLUTTER TO FAIL pedantic: ^1.9.0
moor_ffi: ^0.5.0 moor_ffi: ^0.5.0

View file

@ -1,2 +1,4 @@
#!/bin/sh -e #!/bin/sh -e
pub run test -p vm pub run test -p vm
pub run test_coverage
genhtml -o coverage coverage/lcov.info || true

View file

@ -682,6 +682,9 @@ void main() {
expect(client2.rooms[1].id, client1.rooms[1].id); expect(client2.rooms[1].id, client1.rooms[1].id);
expect(client2.rooms[1].outboundGroupSession.session_key(), sessionKey); expect(client2.rooms[1].outboundGroupSession.session_key(), sessionKey);
} }
await client1.logout();
await client2.logout();
}); });
}); });
} }

View file

@ -207,6 +207,8 @@ void main() {
final resp2 = await event.sendAgain(txid: '1234'); final resp2 = await event.sendAgain(txid: '1234');
expect(resp1, null); expect(resp1, null);
expect(resp2, '42'); expect(resp2, '42');
await matrix.dispose(closeDatabase: true);
}); });
test('requestKey', () async { test('requestKey', () async {
@ -244,6 +246,8 @@ void main() {
}, Room(id: '!1234:example.com', client: matrix)); }, Room(id: '!1234:example.com', client: matrix));
await event.requestKey(); await event.requestKey();
await matrix.dispose(closeDatabase: true);
}); });
}); });
} }

View file

@ -29,7 +29,6 @@ import 'fake_database.dart';
void main() { void main() {
/// All Tests related to device keys /// All Tests related to device keys
group('Room Key Request', () {
test('fromJson', () async { test('fromJson', () async {
var rawJson = <String, dynamic>{ var rawJson = <String, dynamic>{
'content': { 'content': {
@ -59,12 +58,13 @@ void main() {
var room = matrix.getRoomById('!726s6s6q:example.com'); var room = matrix.getRoomById('!726s6s6q:example.com');
if (matrix.encryptionEnabled) { if (matrix.encryptionEnabled) {
await room.createOutboundGroupSession(); await room.createOutboundGroupSession();
rawJson['content']['body']['session_id'] = room.inboundGroupSessions.keys.first; rawJson['content']['body']['session_id'] =
room.inboundGroupSessions.keys.first;
var roomKeyRequest = RoomKeyRequest.fromToDeviceEvent( var roomKeyRequest = RoomKeyRequest.fromToDeviceEvent(
ToDeviceEvent.fromJson(rawJson), matrix); ToDeviceEvent.fromJson(rawJson), matrix);
await roomKeyRequest.forwardKey(); await roomKeyRequest.forwardKey();
} }
}); await matrix.dispose(closeDatabase: true);
}); });
} }

View file

@ -26,7 +26,8 @@ import 'package:famedlysdk/src/event.dart';
import 'package:famedlysdk/src/room.dart'; import 'package:famedlysdk/src/room.dart';
import 'package:famedlysdk/src/user.dart'; import 'package:famedlysdk/src/user.dart';
import 'package:famedlysdk/src/utils/matrix_file.dart'; import 'package:famedlysdk/src/utils/matrix_file.dart';
import 'package:famedlysdk/src/database/database.dart' show DbRoom, DbRoomState, DbRoomAccountData; import 'package:famedlysdk/src/database/database.dart'
show DbRoom, DbRoomState, DbRoomAccountData;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'fake_matrix_api.dart'; import 'fake_matrix_api.dart';
@ -397,15 +398,16 @@ void main() {
expect(room.outboundGroupSession != null, true); expect(room.outboundGroupSession != null, true);
expect(room.outboundGroupSession.session_id().isNotEmpty, true); expect(room.outboundGroupSession.session_id().isNotEmpty, true);
expect( expect(
room.inboundGroupSessions.containsKey(room.outboundGroupSession.session_id()), room.inboundGroupSessions
.containsKey(room.outboundGroupSession.session_id()),
true); true);
expect( expect(
room.inboundGroupSessions[room.outboundGroupSession.session_id()] room.inboundGroupSessions[room.outboundGroupSession.session_id()]
.content['session_key'], .content['session_key'],
room.outboundGroupSession.session_key()); room.outboundGroupSession.session_key());
expect( expect(
room.inboundGroupSessions[room.outboundGroupSession.session_id()].indexes room.inboundGroupSessions[room.outboundGroupSession.session_id()]
.length, .indexes.length,
0); 0);
}); });
@ -442,5 +444,9 @@ void main() {
expect(decryptedEvent.typeKey, 'm.room.message'); expect(decryptedEvent.typeKey, 'm.room.message');
expect(decryptedEvent.content, payload); expect(decryptedEvent.content, payload);
}); });
test('logout', () async {
await matrix.logout();
});
}); });
} }