Fix unique constraint tests

This commit is contained in:
westito 2022-04-02 20:12:13 +02:00
parent 171cf88aac
commit ec53328e49
3 changed files with 7 additions and 6 deletions

View File

@ -62,7 +62,7 @@ void main() {
); );
await db.into(db.users).insert( await db.into(db.users).insert(
UsersCompanion.insert( UsersCompanion.insert(
name: 'User name', name: 'User name 2',
profilePicture: Uint8List(0), profilePicture: Uint8List(0),
creationTime: Value(secondTime)), creationTime: Value(secondTime)),
); );

View File

@ -20,7 +20,7 @@ void main() {
b.insertAll(db.users, [ b.insertAll(db.users, [
for (var i = 0; i < 1000; i++) for (var i = 0; i < 1000; i++)
UsersCompanion.insert( UsersCompanion.insert(
name: 'user name', profilePicture: Uint8List(0)), name: 'user name $i', profilePicture: Uint8List(0)),
]); ]);
}); });

View File

@ -22,8 +22,9 @@ void main() {
verify(mockExecutor.runCustom( verify(mockExecutor.runCustom(
'CREATE TABLE IF NOT EXISTS todos ' 'CREATE TABLE IF NOT EXISTS todos '
'(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, title TEXT NULL, ' '(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, title TEXT NULL, '
'content TEXT NOT NULL, target_date INTEGER NULL, ' 'content TEXT NOT NULL, target_date INTEGER NULL UNIQUE, '
'category INTEGER NULL REFERENCES categories (id));', 'category INTEGER NULL REFERENCES categories (id), '
'UNIQUE (title, category), UNIQUE (title, target_date));',
[])); []));
verify(mockExecutor.runCustom( verify(mockExecutor.runCustom(
@ -39,7 +40,7 @@ void main() {
verify(mockExecutor.runCustom( verify(mockExecutor.runCustom(
'CREATE TABLE IF NOT EXISTS users ' 'CREATE TABLE IF NOT EXISTS users '
'(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, ' '(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, '
'name TEXT NOT NULL, ' 'name TEXT NOT NULL UNIQUE, '
'is_awesome INTEGER NOT NULL DEFAULT 1 CHECK (is_awesome IN (0, 1)), ' 'is_awesome INTEGER NOT NULL DEFAULT 1 CHECK (is_awesome IN (0, 1)), '
'profile_picture BLOB NOT NULL, ' 'profile_picture BLOB NOT NULL, '
'creation_time INTEGER NOT NULL ' 'creation_time INTEGER NOT NULL '
@ -91,7 +92,7 @@ void main() {
verify(mockExecutor.runCustom( verify(mockExecutor.runCustom(
'CREATE TABLE IF NOT EXISTS users ' 'CREATE TABLE IF NOT EXISTS users '
'(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, ' '(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, '
'name TEXT NOT NULL, ' 'name TEXT NOT NULL UNIQUE, '
'is_awesome INTEGER NOT NULL DEFAULT 1 CHECK (is_awesome IN (0, 1)), ' 'is_awesome INTEGER NOT NULL DEFAULT 1 CHECK (is_awesome IN (0, 1)), '
'profile_picture BLOB NOT NULL, ' 'profile_picture BLOB NOT NULL, '
'creation_time INTEGER NOT NULL ' 'creation_time INTEGER NOT NULL '