Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All test in floor_generator run now #808

Merged
merged 19 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
timeout-minutes: 10

container:
image: dart:3.2.6
image: dart:3.3.0

steps:
- name: Check out code
Expand All @@ -35,7 +35,7 @@ jobs:
timeout-minutes: 10

container:
image: dart:3.2.6
image: dart:3.3.0

steps:
- name: Check out code
Expand Down
1 change: 1 addition & 0 deletions floor/lib/src/sqflite_database_factory.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';

import 'package:path/path.dart';
// ignore: unnecessary_import
import 'package:sqflite/sqflite.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';

Expand Down
30 changes: 15 additions & 15 deletions floor/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -301,26 +301,26 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
sha256: cdd14e3836065a1f6302a236ec8b5f700695c803c57ae11a1c84df31e6bcf831
url: "https://pub.dev"
source: hosted
version: "10.0.0"
version: "10.0.3"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
sha256: "9b2ef90589911d665277464e0482b209d39882dffaaf4ef69a3561a3354b2ebc"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.2"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
sha256: fd3cd66cb2bcd7b50dcd3b413af49d78051f809c8b3f6e047962765c15a0d23d
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.0"
lists:
dependency: transitive
description:
Expand Down Expand Up @@ -490,10 +490,10 @@ packages:
dependency: "direct main"
description:
name: sqlparser
sha256: dc384bb1f56d1384ce078edb5ff8247976abdab79d0c83e437210c85f06ecb61
sha256: "7b20045d1ccfb7bc1df7e8f9fee5ae58673fce6ff62cefbb0e0fd7214e90e5a0"
url: "https://pub.dev"
source: hosted
version: "0.34.0"
version: "0.34.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -530,10 +530,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 All @@ -554,10 +554,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.0"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -594,10 +594,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
sha256: a2662fb1f114f4296cf3f5a50786a2d888268d7776cf681aa17d660ffa23b246
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "14.0.0"
watcher:
dependency: transitive
description:
Expand All @@ -624,4 +624,4 @@ packages:
version: "3.1.1"
sdks:
dart: ">=3.2.6 <4.0.0"
flutter: ">=3.7.0"
flutter: ">=3.18.0-18.0.pre.54"
2 changes: 1 addition & 1 deletion floor/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ dev_dependencies:
sdk: flutter
matcher: ^0.12.16+1
mockito: ^5.4.4
sqflite_common: ^2.5.3
sqflite_common: ^2.5.3
8 changes: 4 additions & 4 deletions floor_annotation/lib/src/entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ class Entity {
final String? tableName;

/// List of indices on the table.
final List<Index> indices;
final List<Index>? indices;

/// List of [ForeignKey] constraints on this entity.
final List<ForeignKey> foreignKeys;
final List<ForeignKey>? foreignKeys;

/// List of primary key column names.
final List<String> primaryKeys;
final List<String>? primaryKeys;

/// Whether the table is a "WITHOUT ROWID table".
final bool withoutRowid;
final bool? withoutRowid;

/// Marks a class as a database entity (table).
const Entity({
Expand Down
8 changes: 4 additions & 4 deletions floor_generator/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ packages:
dependency: "direct dev"
description:
name: dart_style
sha256: "40ae61a5d43feea6d24bd22c0537a6629db858963b99b4bc1c3db80676f32368"
sha256: "25b4624c231844a7a70a3817a729a6190a751ef1c07ded256e126a3b72261444"
url: "https://pub.dev"
source: hosted
version: "2.3.4"
version: "2.3.5"
file:
dependency: transitive
description:
Expand Down Expand Up @@ -452,10 +452,10 @@ packages:
dependency: "direct main"
description:
name: strings
sha256: "1f3db7347b8dfd9844ee7fb34883cffbe6cc723a63cb9f4a0aa19e619304b030"
sha256: b33f40c4dd3e597bf6d9e7f4f4dc282dad0f19b07d9f320cb5c2183859cbccf5
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "3.1.1"
term_glyph:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion floor_generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies:
path: ../floor_annotation
meta:
source_gen: ^1.5.0
strings: ^3.0.0
strings: ^3.1.1

dev_dependencies:
build_test: ^2.2.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void main() {

final actual = () => element.getTypeConverters(typeConverterScope);

expect(actual, throwsProcessorError());
expect(actual, throwsUnresolvedAnnotationException());
});
stephanmantel marked this conversation as resolved.
Show resolved Hide resolved

test('throws error when empty list in annotation', () async {
Expand Down
51 changes: 1 addition & 50 deletions floor_generator/test/processor/entity_processor_test.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:build_test/build_test.dart';
import 'package:floor_annotation/floor_annotation.dart' as annotations;
import 'package:floor_generator/misc/constants.dart';
import 'package:floor_generator/processor/entity_processor.dart';
import 'package:floor_generator/processor/error/entity_processor_error.dart';
import 'package:floor_generator/processor/error/queryable_processor_error.dart';
Expand All @@ -14,7 +13,6 @@ import 'package:floor_generator/value_object/primary_key.dart';
import 'package:source_gen/source_gen.dart';
import 'package:test/test.dart';

import '../fakes.dart';
import '../test_utils.dart';

void main() {
Expand Down Expand Up @@ -68,7 +66,7 @@ void main() {
primaryKeys:null,
withoutRowid:null,
)
@Fts3(tokenizerArgs:null)
@Fts3()
class Person {
@primaryKey
final int id;
Expand Down Expand Up @@ -279,50 +277,6 @@ void main() {
);
expect(actual, equals(expected));
});

test('error with wrong onUpdate Annotation', () async {
final classElements = await _createClassElements('''
@entity
class Person {
@primaryKey
final int id;

final String name;

Person(this.id, this.name);
}

@Entity(
foreignKeys: [
ForeignKey(
childColumns: ['owner_id'],
parentColumns: ['id'],
entity: Person,
onUpdate: null
onDelete: ForeignKeyAction.setNull,
)
],
)
class Dog {
@primaryKey
final int id;

final String name;

@ColumnInfo(name: 'owner_id')
final int ownerId;

Dog(this.id, this.name, this.ownerId);
}
''');

final processor = EntityProcessor(classElements[1], {});
expect(
processor.process,
throwsInvalidGenerationSourceError(
EntityProcessorError(classElements[1]).wrongForeignKeyAction(
FakeDartObject(), ForeignKeyField.onUpdate)));
});
dkaera marked this conversation as resolved.
Show resolved Hide resolved
});

group('fts keys', () {
Expand Down Expand Up @@ -566,7 +520,6 @@ void main() {
childColumns: ['owner_id'],
parentColumns: [],
entity: Person,
onUpdate: null
onDelete: ForeignKeyAction.setNull,
)
],
Expand Down Expand Up @@ -608,7 +561,6 @@ void main() {
childColumns: [],
parentColumns: ['id'],
entity: Person,
onUpdate: null
onDelete: ForeignKeyAction.setNull,
)
],
Expand Down Expand Up @@ -675,7 +627,6 @@ void main() {
childColumns: ['owner_id'],
parentColumns: ['id'],
entity: Person,
onUpdate: null
onDelete: ForeignKeyAction.setNull,
)
],
Expand Down
4 changes: 4 additions & 0 deletions floor_generator/test/test_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ Matcher throwsProcessorError([
}
}

Matcher throwsUnresolvedAnnotationException() {
return throwsA(isA<UnresolvedAnnotationException>());
}

stephanmantel marked this conversation as resolved.
Show resolved Hide resolved
Future<Dao> createDao(final String methodSignature) async {
final library = await resolveSource('''
library test;
Expand Down
Loading