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

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

@ -44,11 +44,13 @@ extension NextcloudNotificationsPushProxy on NotificationsClient {
final response = await request.close(); final response = await request.close();
if (response.statusCode != 200) { if (response.statusCode != 200) {
// coverage:ignore-start
throw ApiException( throw ApiException(
response.statusCode, response.statusCode,
{}, // TODO {}, // TODO
await response.bodyBytes, 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 /// Returns if the file is a directory
bool get isDirectory => path.endsWith('/') || (isCollection ?? false); bool get isDirectory => path.endsWith('/') || (isCollection ?? false);
// coverage:ignore-start
@override @override
String toString() => String toString() =>
// ignore: lines_longer_than_80_chars // ignore: lines_longer_than_80_chars
'WebDavFile{name: $name, id: $id, isDirectory: $isDirectory, path: $path, mimeType: $mimeType, size: $size, modificationTime: $lastModified, shareTypes: $shareTypes}'; '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] /// 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 /// Name of the prop
final String name; final String name;
// coverage:ignore-start
@override @override
String toString() => name; String toString() => name;
// coverage:ignore-end
} }

1
packages/nextcloud/test/helper.dart

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

Loading…
Cancel
Save