Update test cases

This commit is contained in:
thomashii@dukefirehawk.com 2021-05-05 09:28:47 +08:00
parent 975c42000d
commit 41569aa53f

View file

@ -123,11 +123,12 @@ class UserQuery extends Query<User, UserQueryWhere> {
password: (row[4] as String?), password: (row[4] as String?),
email: (row[5] as String?)); email: (row[5] as String?));
if (row.length > 6) { if (row.length > 6) {
model = model.copyWith(roles: [ var roleOpt = RoleQuery.parseRow(row.skip(6).take(4).toList());
RoleQuery.parseRow(row.skip(6).take(4).toList()).firstOrNull roleOpt.ifPresent((role) {
]); model = model.copyWith(roles: [role]);
});
} }
return Optional.ofNullable(model); return Optional.of(model);
} }
@override @override
@ -597,8 +598,8 @@ class User extends _User {
this.username, this.username,
this.password, this.password,
this.email, this.email,
List<_Role?>? roles}) List<_Role> roles = const []})
: this.roles = List.unmodifiable(roles ?? []); : this.roles = List.unmodifiable(roles);
/// A unique identifier corresponding to this item. /// A unique identifier corresponding to this item.
@override @override
@ -631,7 +632,7 @@ class User extends _User {
String? username, String? username,
String? password, String? password,
String? email, String? email,
List<_Role?>? roles}) { List<_Role> roles = const []}) {
return User( return User(
id: id ?? this.id, id: id ?? this.id,
createdAt: createdAt ?? this.createdAt, createdAt: createdAt ?? this.createdAt,
@ -639,7 +640,7 @@ class User extends _User {
username: username ?? this.username, username: username ?? this.username,
password: password ?? this.password, password: password ?? this.password,
email: email ?? this.email, email: email ?? this.email,
roles: roles ?? this.roles); roles: roles);
} }
bool operator ==(other) { bool operator ==(other) {
@ -812,7 +813,7 @@ class UserSerializer extends Codec<User, Map?> {
roles: map['roles'] is Iterable roles: map['roles'] is Iterable
? List.unmodifiable(((map['roles'] as Iterable).whereType<Map>()) ? List.unmodifiable(((map['roles'] as Iterable).whereType<Map>())
.map(RoleSerializer.fromMap)) .map(RoleSerializer.fromMap))
: null); : []);
} }
static Map<String, dynamic>? toMap(_User? model) { static Map<String, dynamic>? toMap(_User? model) {