Skip to content

Commit

Permalink
Sort uris in error for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexios80 committed Oct 25, 2024
1 parent 64a3f7c commit 4ddce35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions hive_generator/lib/src/registrar_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ class RegistrarBuilder implements Builder {
adapters.addAll(data.adapters);
if (data.registrarLocation) {
if (registrarUri != null) {
final sortedUris =
[registrarUri, uri].map((e) => e.toString()).toList()..sort();
final urisString = sortedUris.map((e) => '- $e').join('\n');
throw HiveError('''
GenerateAdapters annotation found in more than one file:
- $registrarUri
- $uri''');
$urisString''');
}
registrarUri = uri;
}
Expand Down
6 changes: 3 additions & 3 deletions hive_generator/test/registrar_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ class Type {}
''',
'lib/hive_adapters_2.dart': '''
import 'package:hive_ce/hive.dart';
part 'hive_adapters.g.dart';
part 'hive_adapters_2.g.dart';
@GenerateAdapters([AdapterSpec<Type2>()])
class Type2 {}
''',
},
throws: '''
GenerateAdapters annotation found in more than one file:
- package:hive_ce_generator_test/hive_adapters_2.dart
- package:hive_ce_generator_test/hive_adapters.dart''',
- package:hive_ce_generator_test/hive_adapters.dart
- package:hive_ce_generator_test/hive_adapters_2.dart''',
);
});
});
Expand Down

0 comments on commit 4ddce35

Please sign in to comment.