Browse Source

Merge pull request #83 from jld3103/feature/better-coverage-reports

Make coverage reports more useful
pull/85/head
jld3103 2 years ago committed by GitHub
parent
commit
2f4a4bcf35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      packages/dynamite/lib/src/openapi_builder.dart
  2. 2
      packages/nextcloud/lib/src/helpers.dart
  3. 306
      packages/nextcloud/lib/src/nextcloud.openapi.dart
  4. 2
      packages/nextcloud/lib/src/webdav/file.dart
  5. 2
      packages/nextcloud/lib/src/webdav/props.dart
  6. 1
      packages/nextcloud/test/helper.dart

21
packages/dynamite/lib/src/openapi_builder.dart

@ -991,7 +991,7 @@ class OpenAPIBuilder implements Builder {
}
code.write('}');
}
code.write('throw ApiException.fromResponse(response);');
code.write('throw ApiException.fromResponse(response); // coverage:ignore-line\n');
} else {
b.returns = refer('Future');
}
@ -1028,6 +1028,7 @@ class OpenAPIBuilder implements Builder {
if (registeredJsonObjects.isNotEmpty) {
output.addAll([
'// coverage:ignore-start',
'final _deserializers = <Type, dynamic Function(dynamic)>{',
for (final name in registeredJsonObjects) ...[
'$name: (final data) => ${_deserializeFunctionForType(
@ -1077,6 +1078,7 @@ class OpenAPIBuilder implements Builder {
'T deserialize<T>(final dynamic data) => _deserializers[T]!(data) as T;',
'',
'dynamic serialize<T>(final T data) => _serializers[T]!(data);',
'// coverage:ignore-end',
]);
}
@ -1085,7 +1087,22 @@ class OpenAPIBuilder implements Builder {
);
await buildStep.writeAsString(
outputId,
formatter.format(output.join('\n')),
formatter.format(
output
.join('\n')
.replaceAll(
'Map<String, dynamic> toJson()',
' // coverage:ignore-start\nMap<String, dynamic> toJson()',
)
.replaceAll(
'ToJson(this);',
'ToJson(this);\n // coverage:ignore-end\n',
)
.replaceAll(
'dynamic toJson() => _data;',
' // coverage:ignore-start\ndynamic toJson() => _data;\n // coverage:ignore-end\n',
),
),
);
} catch (e, s) {
print(s);

2
packages/nextcloud/lib/src/helpers.dart

@ -44,11 +44,13 @@ extension NextcloudNotificationsPushProxy on NotificationsClient {
final response = await request.close();
if (response.statusCode != 200) {
// coverage:ignore-start
throw ApiException(
response.statusCode,
{}, // TODO
await response.bodyBytes,
);
// coverage:ignore-end
}
}

306
packages/nextcloud/lib/src/nextcloud.openapi.dart

File diff suppressed because it is too large Load Diff

2
packages/nextcloud/lib/src/webdav/file.dart

@ -149,10 +149,12 @@ class WebDavFile {
/// Returns if the file is a directory
bool get isDirectory => path.endsWith('/') || (isCollection ?? false);
// coverage:ignore-start
@override
String toString() =>
// ignore: lines_longer_than_80_chars
'WebDavFile{name: $name, id: $id, isDirectory: $isDirectory, path: $path, mimeType: $mimeType, size: $size, modificationTime: $lastModified, shareTypes: $shareTypes}';
// coverage:ignore-end
}
/// Converts a single d:response to a [WebDavFile]

2
packages/nextcloud/lib/src/webdav/props.dart

@ -159,6 +159,8 @@ enum WebDavProps {
/// Name of the prop
final String name;
// coverage:ignore-start
@override
String toString() => name;
// coverage:ignore-end
}

1
packages/nextcloud/test/helper.dart

@ -263,6 +263,7 @@ class TestDockerHelper {
generateCreateUserInstruction(user),
],
],
'RUN ./occ app:enable password_policy',
'',
];

Loading…
Cancel
Save