Skip to content

Commit

Permalink
fix formmating
Browse files Browse the repository at this point in the history
  • Loading branch information
codekeyz committed May 6, 2024
1 parent a035932 commit 1861a4c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 185 deletions.
190 changes: 32 additions & 158 deletions _tests_/lib/test_data.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import 'package:yaroorm_tests/src/models.dart';

typedef UserData = ({
String firstname,
String lastname,
int age,
String homeAddress
});
typedef UserData = ({String firstname, String lastname, int age, String homeAddress});

final usersList = <NewUser>[
/// Ghana Users - [6]
Expand Down Expand Up @@ -47,158 +42,37 @@ final usersList = <NewUser>[
),

/// Nigerian Users - [22]
NewUser(
firstname: 'Abdul',
lastname: 'Ibrahim',
age: 28,
homeAddress: "Owerri, Nigeria"),
NewUser(
firstname: 'Amina',
lastname: 'Sule',
age: 29,
homeAddress: "Owerri, Nigeria"),
NewUser(
firstname: 'Chukwudi',
lastname: 'Okafor',
age: 30,
homeAddress: "Lagos, Nigeria"),
NewUser(
firstname: 'Chioma',
lastname: 'Nwosu',
age: 31,
homeAddress: "Lagos, Nigeria"),
NewUser(
firstname: 'Yusuf',
lastname: 'Aliyu',
age: 32,
homeAddress: "Owerri, Nigeria"),
NewUser(
firstname: 'Blessing',
lastname: 'Okonkwo',
age: 33,
homeAddress: "Owerri, Nigeria"),
NewUser(
firstname: 'Tunde',
lastname: 'Williams',
age: 34,
homeAddress: "Abuja, Nigeria"),
NewUser(
firstname: 'Rukayat',
lastname: 'Sanni',
age: 35,
homeAddress: "Abuja, Nigeria"),
NewUser(
firstname: 'Segun',
lastname: 'Adeleke',
age: 36,
homeAddress: "Lagos, Nigeria"),
NewUser(
firstname: 'Abdullahi',
lastname: 'Mohammed',
age: 46,
homeAddress: "Lagos, Nigeria"),
NewUser(
firstname: 'Chidinma',
lastname: 'Onyeka',
age: 47,
homeAddress: "Owerri, Nigeria"),
NewUser(
firstname: 'Bola',
lastname: 'Akinwumi',
age: 48,
homeAddress: "Owerri, Nigeria"),
NewUser(
firstname: 'Haruna',
lastname: 'Bello',
age: 49,
homeAddress: "Lagos, Nigeria"),
NewUser(
firstname: 'Habiba',
lastname: 'Yusuf',
age: 50,
homeAddress: "Owerri, Nigeria"),
NewUser(
firstname: 'Tochukwu',
lastname: 'Eze',
age: 50,
homeAddress: "Lagos, Nigeria"),
NewUser(
firstname: 'Ade',
lastname: 'Ogunbanjo',
age: 50,
homeAddress: "Owerri, Nigeria"),
NewUser(
firstname: 'Zainab',
lastname: 'Abubakar',
age: 50,
homeAddress: "Lagos, Nigeria"),
NewUser(
firstname: 'Chijioke',
lastname: 'Nwachukwu',
age: 54,
homeAddress: "Owerri, Nigeria"),
NewUser(
firstname: 'Folake',
lastname: 'Adewale',
age: 55,
homeAddress: "Owerri, Nigeria"),
NewUser(
firstname: 'Mustafa',
lastname: 'Olawale',
age: 56,
homeAddress: "Lagos, Nigeria"),
NewUser(
firstname: 'Halima',
lastname: 'Idris',
age: 57,
homeAddress: "Lagos, Nigeria"),
NewUser(
firstname: 'Chukwuemeka',
lastname: 'Okonkwo',
age: 58,
homeAddress: "Abuja, Nigeria"),
NewUser(firstname: 'Abdul', lastname: 'Ibrahim', age: 28, homeAddress: "Owerri, Nigeria"),
NewUser(firstname: 'Amina', lastname: 'Sule', age: 29, homeAddress: "Owerri, Nigeria"),
NewUser(firstname: 'Chukwudi', lastname: 'Okafor', age: 30, homeAddress: "Lagos, Nigeria"),
NewUser(firstname: 'Chioma', lastname: 'Nwosu', age: 31, homeAddress: "Lagos, Nigeria"),
NewUser(firstname: 'Yusuf', lastname: 'Aliyu', age: 32, homeAddress: "Owerri, Nigeria"),
NewUser(firstname: 'Blessing', lastname: 'Okonkwo', age: 33, homeAddress: "Owerri, Nigeria"),
NewUser(firstname: 'Tunde', lastname: 'Williams', age: 34, homeAddress: "Abuja, Nigeria"),
NewUser(firstname: 'Rukayat', lastname: 'Sanni', age: 35, homeAddress: "Abuja, Nigeria"),
NewUser(firstname: 'Segun', lastname: 'Adeleke', age: 36, homeAddress: "Lagos, Nigeria"),
NewUser(firstname: 'Abdullahi', lastname: 'Mohammed', age: 46, homeAddress: "Lagos, Nigeria"),
NewUser(firstname: 'Chidinma', lastname: 'Onyeka', age: 47, homeAddress: "Owerri, Nigeria"),
NewUser(firstname: 'Bola', lastname: 'Akinwumi', age: 48, homeAddress: "Owerri, Nigeria"),
NewUser(firstname: 'Haruna', lastname: 'Bello', age: 49, homeAddress: "Lagos, Nigeria"),
NewUser(firstname: 'Habiba', lastname: 'Yusuf', age: 50, homeAddress: "Owerri, Nigeria"),
NewUser(firstname: 'Tochukwu', lastname: 'Eze', age: 50, homeAddress: "Lagos, Nigeria"),
NewUser(firstname: 'Ade', lastname: 'Ogunbanjo', age: 50, homeAddress: "Owerri, Nigeria"),
NewUser(firstname: 'Zainab', lastname: 'Abubakar', age: 50, homeAddress: "Lagos, Nigeria"),
NewUser(firstname: 'Chijioke', lastname: 'Nwachukwu', age: 54, homeAddress: "Owerri, Nigeria"),
NewUser(firstname: 'Folake', lastname: 'Adewale', age: 55, homeAddress: "Owerri, Nigeria"),
NewUser(firstname: 'Mustafa', lastname: 'Olawale', age: 56, homeAddress: "Lagos, Nigeria"),
NewUser(firstname: 'Halima', lastname: 'Idris', age: 57, homeAddress: "Lagos, Nigeria"),
NewUser(firstname: 'Chukwuemeka', lastname: 'Okonkwo', age: 58, homeAddress: "Abuja, Nigeria"),

/// Kenyan Users - [9]
NewUser(
firstname: 'Kevin',
lastname: 'Luke',
age: 37,
homeAddress: "Nairobi, Kenya"),
NewUser(
firstname: 'Foop', lastname: 'Farr', age: 38, homeAddress: "CBD, Kenya"),
NewUser(
firstname: 'Koin',
lastname: 'Karl',
age: 39,
homeAddress: "Mumbasa, Kenya"),
NewUser(
firstname: 'Moo',
lastname: 'Maa',
age: 40,
homeAddress: "Westlands, Kenya"),
NewUser(
firstname: 'Merh',
lastname: 'Merh',
age: 41,
homeAddress: "Nairobi, Kenya"),
NewUser(
firstname: 'Ibrahim',
lastname: 'Bakare',
age: 42,
homeAddress: "Nairobi, Kenya"),
NewUser(
firstname: 'Grace',
lastname: 'Adegoke',
age: 43,
homeAddress: "Nairobi, Kenya"),
NewUser(
firstname: 'Ahmed',
lastname: 'Umar',
age: 44,
homeAddress: "Nairobi, Kenya"),
NewUser(
firstname: 'Nneka',
lastname: 'Okoli',
age: 45,
homeAddress: "Nairobi, Kenya"),
NewUser(firstname: 'Kevin', lastname: 'Luke', age: 37, homeAddress: "Nairobi, Kenya"),
NewUser(firstname: 'Foop', lastname: 'Farr', age: 38, homeAddress: "CBD, Kenya"),
NewUser(firstname: 'Koin', lastname: 'Karl', age: 39, homeAddress: "Mumbasa, Kenya"),
NewUser(firstname: 'Moo', lastname: 'Maa', age: 40, homeAddress: "Westlands, Kenya"),
NewUser(firstname: 'Merh', lastname: 'Merh', age: 41, homeAddress: "Nairobi, Kenya"),
NewUser(firstname: 'Ibrahim', lastname: 'Bakare', age: 42, homeAddress: "Nairobi, Kenya"),
NewUser(firstname: 'Grace', lastname: 'Adegoke', age: 43, homeAddress: "Nairobi, Kenya"),
NewUser(firstname: 'Ahmed', lastname: 'Umar', age: 44, homeAddress: "Nairobi, Kenya"),
NewUser(firstname: 'Nneka', lastname: 'Okoli', age: 45, homeAddress: "Nairobi, Kenya"),
];
18 changes: 6 additions & 12 deletions _tests_/test/integration/e2e_basic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ void runBasicE2ETest(String connectionName) {
expect(driver.isOpen, isTrue);
});

test('should have no tables',
() async => expect(await driver.hasTable('users'), isFalse));
test('should have no tables', () async => expect(await driver.hasTable('users'), isFalse));

test('should execute migration', () async {
await runMigrator(connectionName, 'migrate');
Expand Down Expand Up @@ -49,8 +48,7 @@ void runBasicE2ETest(String connectionName) {
});

group('Aggregate Functions', () {
final query = UserQuery.driver(driver)
.where((user) => user.$isLike('home_address', '%%, Ghana'));
final query = UserQuery.driver(driver).where((user) => user.$isLike('home_address', '%%, Ghana'));
List<User> usersInGhana = [];

setUpAll(() async {
Expand Down Expand Up @@ -84,8 +82,7 @@ void runBasicE2ETest(String connectionName) {

test('concat', () async {
Matcher matcher(String separator) {
if ([DatabaseDriverType.sqlite, DatabaseDriverType.pgsql]
.contains(driver.type)) {
if ([DatabaseDriverType.sqlite, DatabaseDriverType.pgsql].contains(driver.type)) {
return equals(usersInGhana.map((e) => e.age).join(separator));
}

Expand Down Expand Up @@ -130,13 +127,11 @@ void runBasicE2ETest(String connectionName) {
final updatedResult = await age50Users.findMany();
expect(updatedResult.length, 4);
expect(updatedResult.every((e) => e.age == 50), isTrue);
expect(
updatedResult.every((e) => e.homeAddress == 'Keta, Ghana'), isTrue);
expect(updatedResult.every((e) => e.homeAddress == 'Keta, Ghana'), isTrue);
});

test('should fetch only users in Ghana', () async {
final userQuery = UserQuery.driver(driver)
.where((user) => user.$isLike('home_address', '%, Ghana'));
final userQuery = UserQuery.driver(driver).where((user) => user.$isLike('home_address', '%, Ghana'));

final usersInGhana = await userQuery.findMany();
expect(usersInGhana.length, 10);
Expand Down Expand Up @@ -192,8 +187,7 @@ void runBasicE2ETest(String connectionName) {
});

test('should delete many users', () async {
final query = UserQuery.driver(driver)
.where((user) => user.$isLike('home_address', '%, Nigeria'));
final query = UserQuery.driver(driver).where((user) => user.$isLike('home_address', '%, Nigeria'));
expect(await query.findMany(), isNotEmpty);

await query.delete();
Expand Down
21 changes: 6 additions & 15 deletions _tests_/test/integration/e2e_relation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,15 @@ void runRelationsE2ETest(String connectionName) {
orderBy: [OrderPostBy.title(order: OrderDirection.desc)],
);
expect(posts, hasLength(3));
expect(
posts.map((e) => {
'id': e.id,
'title': e.title,
'desc': e.description,
'userId': e.userId
}),
[
{'id': 3, 'title': 'Coo Kie 3', 'desc': 'foo bar 6', 'userId': 1},
{'id': 2, 'title': 'Bee Moo 2', 'desc': 'foo bar 5', 'userId': 1},
{'id': 1, 'title': 'Aoo bar 1', 'desc': 'foo bar 4', 'userId': 1}
]);
expect(posts.map((e) => {'id': e.id, 'title': e.title, 'desc': e.description, 'userId': e.userId}), [
{'id': 3, 'title': 'Coo Kie 3', 'desc': 'foo bar 6', 'userId': 1},
{'id': 2, 'title': 'Bee Moo 2', 'desc': 'foo bar 5', 'userId': 1},
{'id': 1, 'title': 'Aoo bar 1', 'desc': 'foo bar 4', 'userId': 1}
]);
});

test('should fetch posts with owner', () async {
final posts = await PostQuery.driver(driver)
.withRelations((post) => [post.owner])
.findMany();
final posts = await PostQuery.driver(driver).withRelations((post) => [post.owner]).findMany();

final owner = await posts.first.owner.value;
expect(
Expand Down

0 comments on commit 1861a4c

Please sign in to comment.