diff --git a/test/error_test.dart b/test/error_test.dart deleted file mode 100644 index 3b90980..0000000 --- a/test/error_test.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'dart:io'; - -import 'package:build/build.dart'; -import 'package:build_test/build_test.dart'; -import 'package:isar_generator/isar_generator.dart'; -import 'package:test/test.dart'; - -void main() { - group('Error case', () { - for (final file in Directory('test/errors').listSync(recursive: true)) { - if (file is! File || !file.path.endsWith('.dart')) continue; - - test(file.path, () async { - final content = await file.readAsLines(); - - final errorMessage = content.first.split('//').last.trim(); - - var error = ''; - try { - await testBuilder( - getIsarGenerator(BuilderOptions.empty), - {'a|${file.path}': content.join('\n')}, - reader: await PackageAssetReader.currentIsolate(), - ); - } catch (e) { - error = e.toString(); - } - - expect(error.toLowerCase(), contains(errorMessage.toLowerCase())); - }); - } - }); -} diff --git a/test/errors/class/abstract.dart b/test/errors/class/abstract.dart deleted file mode 100644 index b116529..0000000 --- a/test/errors/class/abstract.dart +++ /dev/null @@ -1,8 +0,0 @@ -// must not be abstract - -import 'package:isar/isar.dart'; - -@collection -abstract class Model { - Id? id; -} diff --git a/test/errors/class/collection_supertype.dart b/test/errors/class/collection_supertype.dart deleted file mode 100644 index e6e3f8d..0000000 --- a/test/errors/class/collection_supertype.dart +++ /dev/null @@ -1,19 +0,0 @@ -// supertype annotated with @collection - -import 'package:isar/isar.dart'; - -@collection -class Supertype { - Id? id; -} - -class Subtype implements Supertype { - @override - Id? id; -} - -@collection -class Model implements Subtype { - @override - Id? id; -} diff --git a/test/errors/class/constructor_named.dart b/test/errors/class/constructor_named.dart deleted file mode 100644 index 713f795..0000000 --- a/test/errors/class/constructor_named.dart +++ /dev/null @@ -1,10 +0,0 @@ -// unnamed constructor - -import 'package:isar/isar.dart'; - -@collection -class Model { - Model.create(); - - Id? id; -} diff --git a/test/errors/class/constructor_unknown_parameter.dart b/test/errors/class/constructor_unknown_parameter.dart deleted file mode 100644 index 768e349..0000000 --- a/test/errors/class/constructor_unknown_parameter.dart +++ /dev/null @@ -1,13 +0,0 @@ -// constructor parameter does not match a property - -import 'package:isar/isar.dart'; - -@collection -class Model { - // ignore: avoid_unused_constructor_parameters - Model(this.prop1, String somethingElse); - - Id? id; - - final String prop1; -} diff --git a/test/errors/class/constructor_wrong_parameter.dart b/test/errors/class/constructor_wrong_parameter.dart deleted file mode 100644 index 1274a5c..0000000 --- a/test/errors/class/constructor_wrong_parameter.dart +++ /dev/null @@ -1,13 +0,0 @@ -// constructor parameter type does not match property type - -import 'package:isar/isar.dart'; - -@collection -class Model { - // ignore: avoid_unused_constructor_parameters - Model(int prop1); - - Id? id; - - String prop1 = '5'; -} diff --git a/test/errors/class/enum.dart b/test/errors/class/enum.dart deleted file mode 100644 index a51d088..0000000 --- a/test/errors/class/enum.dart +++ /dev/null @@ -1,7 +0,0 @@ -// only classes - -import 'package:isar/isar.dart'; - -// ignore: invalid_annotation_target -@collection -enum Test { a, b, c } diff --git a/test/errors/class/invalid_name.dart b/test/errors/class/invalid_name.dart deleted file mode 100644 index b116529..0000000 --- a/test/errors/class/invalid_name.dart +++ /dev/null @@ -1,8 +0,0 @@ -// must not be abstract - -import 'package:isar/isar.dart'; - -@collection -abstract class Model { - Id? id; -} diff --git a/test/errors/class/mixin.dart b/test/errors/class/mixin.dart deleted file mode 100644 index a6a6374..0000000 --- a/test/errors/class/mixin.dart +++ /dev/null @@ -1,7 +0,0 @@ -// only classes - -import 'package:isar/isar.dart'; - -// ignore: invalid_annotation_target -@collection -mixin Test {} diff --git a/test/errors/class/private.dart b/test/errors/class/private.dart deleted file mode 100644 index aa545b9..0000000 --- a/test/errors/class/private.dart +++ /dev/null @@ -1,9 +0,0 @@ -// must be public - -import 'package:isar/isar.dart'; - -@collection -// ignore: unused_element -class _Model { - Id? id; -} diff --git a/test/errors/class/variable.dart b/test/errors/class/variable.dart deleted file mode 100644 index 543a78e..0000000 --- a/test/errors/class/variable.dart +++ /dev/null @@ -1,7 +0,0 @@ -// only classes - -import 'package:isar/isar.dart'; - -// ignore: invalid_annotation_target -@collection -const t = 'hello'; diff --git a/test/errors/id/duplicate.dart b/test/errors/id/duplicate.dart deleted file mode 100644 index e96e21f..0000000 --- a/test/errors/id/duplicate.dart +++ /dev/null @@ -1,10 +0,0 @@ -// two or more properties with type "Id" defined - -import 'package:isar/isar.dart'; - -@collection -class Test { - Id? id1; - - Id? id2; -} diff --git a/test/errors/id/missing.dart b/test/errors/id/missing.dart deleted file mode 100644 index e414174..0000000 --- a/test/errors/id/missing.dart +++ /dev/null @@ -1,10 +0,0 @@ -// no id property defined - -import 'package:isar/isar.dart'; - -@collection -class Test { - late int id; - - late String name; -} diff --git a/test/errors/index/composite_double_not_last.dart b/test/errors/index/composite_double_not_last.dart deleted file mode 100644 index 135b56b..0000000 --- a/test/errors/index/composite_double_not_last.dart +++ /dev/null @@ -1,13 +0,0 @@ -// only the last property of a composite index may be a double value - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index(composite: [CompositeIndex('val2')]) - double? val1; - - String? val2; -} diff --git a/test/errors/index/composite_non_hashed_list.dart b/test/errors/index/composite_non_hashed_list.dart deleted file mode 100644 index e93241e..0000000 --- a/test/errors/index/composite_non_hashed_list.dart +++ /dev/null @@ -1,13 +0,0 @@ -// composite indexes do not support non-hashed lists - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index(composite: [CompositeIndex('str')], type: IndexType.value) - List? list; - - String? str; -} diff --git a/test/errors/index/composite_string_value_not_last.dart b/test/errors/index/composite_string_value_not_last.dart deleted file mode 100644 index 52efbf8..0000000 --- a/test/errors/index/composite_string_value_not_last.dart +++ /dev/null @@ -1,13 +0,0 @@ -// last property of a composite index may be a non-hashed string - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index(composite: [CompositeIndex('str2')], type: IndexType.value) - String? str1; - - String? str2; -} diff --git a/test/errors/index/contains_id.dart b/test/errors/index/contains_id.dart deleted file mode 100644 index fd45fb2..0000000 --- a/test/errors/index/contains_id.dart +++ /dev/null @@ -1,11 +0,0 @@ -// ids cannot be indexed - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index(composite: [CompositeIndex('id')]) - String? str; -} diff --git a/test/errors/index/double_list_hashed.dart b/test/errors/index/double_list_hashed.dart deleted file mode 100644 index 84563d4..0000000 --- a/test/errors/index/double_list_hashed.dart +++ /dev/null @@ -1,11 +0,0 @@ -// list may must not be hashed - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index(type: IndexType.hash) - List? list; -} diff --git a/test/errors/index/duplicate_name.dart b/test/errors/index/duplicate_name.dart deleted file mode 100644 index 17e6cab..0000000 --- a/test/errors/index/duplicate_name.dart +++ /dev/null @@ -1,14 +0,0 @@ -// same name - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index(name: 'myindex') - String? prop1; - - @Index(name: 'myindex') - String? prop2; -} diff --git a/test/errors/index/duplicate_property.dart b/test/errors/index/duplicate_property.dart deleted file mode 100644 index 01c53f0..0000000 --- a/test/errors/index/duplicate_property.dart +++ /dev/null @@ -1,13 +0,0 @@ -// composite index contains duplicate properties - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index(composite: [CompositeIndex('str1')], type: IndexType.value) - String? str1; - - String? str2; -} diff --git a/test/errors/index/invalid_name.dart b/test/errors/index/invalid_name.dart deleted file mode 100644 index 171fe3a..0000000 --- a/test/errors/index/invalid_name.dart +++ /dev/null @@ -1,11 +0,0 @@ -// names must not be blank or start with "_" - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index(name: '_index') - String? str; -} diff --git a/test/errors/index/non_string_hashed.dart b/test/errors/index/non_string_hashed.dart deleted file mode 100644 index 63267d6..0000000 --- a/test/errors/index/non_string_hashed.dart +++ /dev/null @@ -1,11 +0,0 @@ -// only strings and lists may be hashed - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index(type: IndexType.hash) - int? val; -} diff --git a/test/errors/index/non_string_list_hashed_elements.dart b/test/errors/index/non_string_list_hashed_elements.dart deleted file mode 100644 index 4f119fc..0000000 --- a/test/errors/index/non_string_list_hashed_elements.dart +++ /dev/null @@ -1,11 +0,0 @@ -// only string lists may have hashed elements - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index(type: IndexType.hashElements) - List? list; -} diff --git a/test/errors/index/non_unique_replace.dart b/test/errors/index/non_unique_replace.dart deleted file mode 100644 index 9a49b37..0000000 --- a/test/errors/index/non_unique_replace.dart +++ /dev/null @@ -1,11 +0,0 @@ -// only unique indexes can replace - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index(replace: true) - String? str; -} diff --git a/test/errors/index/object_hashed.dart b/test/errors/index/object_hashed.dart deleted file mode 100644 index dd20d11..0000000 --- a/test/errors/index/object_hashed.dart +++ /dev/null @@ -1,14 +0,0 @@ -// objects may not be indexed - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index() - EmbeddedModel? obj; -} - -@embedded -class EmbeddedModel {} diff --git a/test/errors/index/object_list_hashed.dart b/test/errors/index/object_list_hashed.dart deleted file mode 100644 index d149e19..0000000 --- a/test/errors/index/object_list_hashed.dart +++ /dev/null @@ -1,14 +0,0 @@ -// objects may not be indexed - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index(type: IndexType.hash) - List? list; -} - -@embedded -class EmbeddedModel {} diff --git a/test/errors/index/property_does_not_exist.dart b/test/errors/index/property_does_not_exist.dart deleted file mode 100644 index 806515e..0000000 --- a/test/errors/index/property_does_not_exist.dart +++ /dev/null @@ -1,11 +0,0 @@ -// property does not exist - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Index(composite: [CompositeIndex('myProp')]) - String? str; -} diff --git a/test/errors/link/backlink_target_does_no_exist.dart b/test/errors/link/backlink_target_does_no_exist.dart deleted file mode 100644 index ea285c2..0000000 --- a/test/errors/link/backlink_target_does_no_exist.dart +++ /dev/null @@ -1,16 +0,0 @@ -// target of backlink does not exist - -import 'package:isar/isar.dart'; - -@collection -class Model1 { - Id? id; - - @Backlink(to: 'abc') - final IsarLink link = IsarLink(); -} - -@collection -class Model2 { - Id? id; -} diff --git a/test/errors/link/backlink_target_is_backlink.dart b/test/errors/link/backlink_target_is_backlink.dart deleted file mode 100644 index 5d5f48d..0000000 --- a/test/errors/link/backlink_target_is_backlink.dart +++ /dev/null @@ -1,19 +0,0 @@ -// target of backlink is also a backlink - -import 'package:isar/isar.dart'; - -@collection -class Model1 { - Id? id; - - @Backlink(to: 'link') - final IsarLink link = IsarLink(); -} - -@collection -class Model2 { - Id? id; - - @Backlink(to: 'link') - final IsarLink link = IsarLink(); -} diff --git a/test/errors/link/backlink_target_not_a_link.dart b/test/errors/link/backlink_target_not_a_link.dart deleted file mode 100644 index 459ecd3..0000000 --- a/test/errors/link/backlink_target_not_a_link.dart +++ /dev/null @@ -1,18 +0,0 @@ -// target of backlink is not a link - -import 'package:isar/isar.dart'; - -@collection -class Model1 { - Id? id; - - @Backlink(to: 'str') - final IsarLink link = IsarLink(); -} - -@collection -class Model2 { - Id? id; - - String? str; -} diff --git a/test/errors/link/duplicate_name.dart b/test/errors/link/duplicate_name.dart deleted file mode 100644 index 1405c4a..0000000 --- a/test/errors/link/duplicate_name.dart +++ /dev/null @@ -1,18 +0,0 @@ -// same name - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - final IsarLink prop1 = IsarLink(); - - @Name('prop1') - final IsarLinks prop2 = IsarLinks(); -} - -@collection -class Model2 { - Id? id; -} diff --git a/test/errors/link/invalid_name.dart b/test/errors/link/invalid_name.dart deleted file mode 100644 index 47b89a9..0000000 --- a/test/errors/link/invalid_name.dart +++ /dev/null @@ -1,16 +0,0 @@ -// names must not be blank or start with - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Name('_link') - final IsarLink link = IsarLink(); -} - -@collection -class Model2 { - Id? id; -} diff --git a/test/errors/link/late.dart b/test/errors/link/late.dart deleted file mode 100644 index 845cf27..0000000 --- a/test/errors/link/late.dart +++ /dev/null @@ -1,15 +0,0 @@ -// must not be late - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - late IsarLink link; -} - -@collection -class Model2 { - Id? id; -} diff --git a/test/errors/link/nullable.dart b/test/errors/link/nullable.dart deleted file mode 100644 index ab1f588..0000000 --- a/test/errors/link/nullable.dart +++ /dev/null @@ -1,15 +0,0 @@ -// must not be nullable - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - IsarLink? link; -} - -@collection -class Model2 { - Id? id; -} diff --git a/test/errors/link/target_not_a_collection.dart b/test/errors/link/target_not_a_collection.dart deleted file mode 100644 index dd7d3cd..0000000 --- a/test/errors/link/target_not_a_collection.dart +++ /dev/null @@ -1,10 +0,0 @@ -// link target is not annotated with @collection - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - final IsarLink link = IsarLink(); -} diff --git a/test/errors/link/type_nullable.dart b/test/errors/link/type_nullable.dart deleted file mode 100644 index 865d421..0000000 --- a/test/errors/link/type_nullable.dart +++ /dev/null @@ -1,15 +0,0 @@ -// links type must not be nullable - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - final IsarLink link = IsarLink(); -} - -@collection -class Model2 { - Id? id; -} diff --git a/test/errors/property/duplicate_name.dart b/test/errors/property/duplicate_name.dart deleted file mode 100644 index 0b275cb..0000000 --- a/test/errors/property/duplicate_name.dart +++ /dev/null @@ -1,13 +0,0 @@ -// same name - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - String? prop1; - - @Name('prop1') - String? prop2; -} diff --git a/test/errors/property/enum_bool_type.dart b/test/errors/property/enum_bool_type.dart deleted file mode 100644 index d5b4b44..0000000 --- a/test/errors/property/enum_bool_type.dart +++ /dev/null @@ -1,17 +0,0 @@ -// unsupported enum property type - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Enumerated(EnumType.value, 'value') - late MyEnum field; -} - -enum MyEnum { - optionA; - - final bool value = true; -} diff --git a/test/errors/property/enum_double_type.dart b/test/errors/property/enum_double_type.dart deleted file mode 100644 index 17567e6..0000000 --- a/test/errors/property/enum_double_type.dart +++ /dev/null @@ -1,17 +0,0 @@ -// unsupported enum property type - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Enumerated(EnumType.value, 'value') - late MyEnum field; -} - -enum MyEnum { - optionA; - - final double value = 5.5; -} diff --git a/test/errors/property/enum_duplicate.dart b/test/errors/property/enum_duplicate.dart deleted file mode 100644 index 32ce056..0000000 --- a/test/errors/property/enum_duplicate.dart +++ /dev/null @@ -1,21 +0,0 @@ -// has duplicate values - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Enumerated(EnumType.value, 'value') - late MyEnum field; -} - -enum MyEnum { - option1(1), - option2(2), - option3(1); - - const MyEnum(this.value); - - final int value; -} diff --git a/test/errors/property/enum_float_type.dart b/test/errors/property/enum_float_type.dart deleted file mode 100644 index abf3830..0000000 --- a/test/errors/property/enum_float_type.dart +++ /dev/null @@ -1,17 +0,0 @@ -// unsupported enum property type - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Enumerated(EnumType.value, 'value') - late MyEnum field; -} - -enum MyEnum { - optionA; - - final float value = 5.5; -} diff --git a/test/errors/property/enum_list_type.dart b/test/errors/property/enum_list_type.dart deleted file mode 100644 index 75d78e2..0000000 --- a/test/errors/property/enum_list_type.dart +++ /dev/null @@ -1,17 +0,0 @@ -// unsupported enum property type - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Enumerated(EnumType.value, 'value') - late MyEnum prop; -} - -enum MyEnum { - optionA; - - final List value = []; -} diff --git a/test/errors/property/enum_not_annotated.dart b/test/errors/property/enum_not_annotated.dart deleted file mode 100644 index 456e8e4..0000000 --- a/test/errors/property/enum_not_annotated.dart +++ /dev/null @@ -1,14 +0,0 @@ -// enum property must be annotated with @enumerated - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - late MyEnum? prop; -} - -enum MyEnum { - a; -} diff --git a/test/errors/property/enum_null_value.dart b/test/errors/property/enum_null_value.dart deleted file mode 100644 index bdc2e30..0000000 --- a/test/errors/property/enum_null_value.dart +++ /dev/null @@ -1,17 +0,0 @@ -// null values are not supported - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Enumerated(EnumType.value, 'value') - late MyEnum prop; -} - -enum MyEnum { - optionA; - - final String? value = null; -} diff --git a/test/errors/property/enum_object_type.dart b/test/errors/property/enum_object_type.dart deleted file mode 100644 index afa6d96..0000000 --- a/test/errors/property/enum_object_type.dart +++ /dev/null @@ -1,20 +0,0 @@ -// unsupported enum property type - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Enumerated(EnumType.value, 'value') - late MyEnum prop; -} - -enum MyEnum { - optionA; - - final value = EmbeddedModel(); -} - -@embedded -class EmbeddedModel {} diff --git a/test/errors/property/invalid_name.dart b/test/errors/property/invalid_name.dart deleted file mode 100644 index 5bc5341..0000000 --- a/test/errors/property/invalid_name.dart +++ /dev/null @@ -1,11 +0,0 @@ -// names must not be blank or start with "_" - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - @Name('_prop') - String? prop; -} diff --git a/test/errors/property/null_byte.dart b/test/errors/property/null_byte.dart deleted file mode 100644 index c581380..0000000 --- a/test/errors/property/null_byte.dart +++ /dev/null @@ -1,10 +0,0 @@ -// bytes must not be nullable - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - late byte? prop; -} diff --git a/test/errors/property/null_byte_element.dart b/test/errors/property/null_byte_element.dart deleted file mode 100644 index d45c4b1..0000000 --- a/test/errors/property/null_byte_element.dart +++ /dev/null @@ -1,10 +0,0 @@ -// bytes must not be nullable - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - late List prop; -} diff --git a/test/errors/property/unsupported_type.dart b/test/errors/property/unsupported_type.dart deleted file mode 100644 index 68af2cf..0000000 --- a/test/errors/property/unsupported_type.dart +++ /dev/null @@ -1,10 +0,0 @@ -// unsupported type - -import 'package:isar/isar.dart'; - -@collection -class Model { - Id? id; - - late Set? prop; -}