mirror of https://github.com/AMT-Cheif/drift.git
52 lines
1.3 KiB
Dart
52 lines
1.3 KiB
Dart
import 'package:sally/sally.dart';
|
|
import 'package:sally/src/runtime/components/component.dart';
|
|
import 'package:test_api/test_api.dart';
|
|
|
|
import '../data/tables/todos.dart';
|
|
|
|
void main() {
|
|
final expression = GeneratedIntColumn('col', false);
|
|
final db = TodoDb(null);
|
|
|
|
final comparisons = {
|
|
expression.isSmallerThan: '<',
|
|
expression.isSmallerOrEqual: '<=',
|
|
expression.isBiggerOrEqual: '>=',
|
|
expression.isBiggerThan: '>'
|
|
};
|
|
|
|
final comparisonsVal = {
|
|
expression.isSmallerThanValue: '<',
|
|
expression.isSmallerOrEqualValue: '<=',
|
|
expression.isBiggerOrEqualValue: '>=',
|
|
expression.isBiggerThanValue: '>'
|
|
};
|
|
|
|
group('can compare with other expressions', () {
|
|
final compare = GeneratedIntColumn('compare', false);
|
|
|
|
comparisons.forEach((fn, value) {
|
|
test('for operator $value', () {
|
|
final ctx = GenerationContext(db);
|
|
|
|
fn(compare).writeInto(ctx);
|
|
|
|
expect(ctx.sql, 'col $value compare');
|
|
});
|
|
});
|
|
});
|
|
|
|
group('can compare with values', () {
|
|
comparisonsVal.forEach((fn, value) {
|
|
test('for operator $value', () {
|
|
final ctx = GenerationContext(db);
|
|
|
|
fn(12).writeInto(ctx);
|
|
|
|
expect(ctx.sql, 'col $value ?');
|
|
expect(ctx.boundVariables, [12]);
|
|
});
|
|
});
|
|
});
|
|
}
|