Skip to content

Commit

Permalink
Add test for missing primary key
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikvdkaaden committed Mar 28, 2024
1 parent 6b4e5d6 commit 0c21c69
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,10 @@ packages:
dependency: transitive
description:
name: strings
sha256: "1f3db7347b8dfd9844ee7fb34883cffbe6cc723a63cb9f4a0aa19e619304b030"
sha256: b33f40c4dd3e597bf6d9e7f4f4dc282dad0f19b07d9f320cb5c2183859cbccf5
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "3.1.1"
synchronized:
dependency: transitive
description:
Expand Down
15 changes: 15 additions & 0 deletions floor_generator/test/processor/entity_processor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,21 @@ void main() {
throwsInvalidGenerationSourceError(
EntityProcessorError(classElements).missingPrimaryKey));
});
test('one primary key missing in compound primary key', () async {
final classElements = await createClassElement('''
@Entity(primaryKeys: ['ID', 'email'])
class Example {
final int id;
final String email;
}
''');

final processor = EntityProcessor(classElements, {});
expect(
processor.process,
throwsInvalidGenerationSourceError(
EntityProcessorError(classElements).primaryKeyNotFound));
});
test('compound primary key mismatch', () async {
final classElements = await createClassElement('''
@Entity(
Expand Down

0 comments on commit 0c21c69

Please sign in to comment.