import 'package:drift_dev/src/analysis/results/results.dart'; import 'package:test/expect.dart'; import '../../test_utils.dart'; Future analyzeSingleQueryInDriftFile(String driftFile) async { final file = await TestBackend.analyzeSingle(driftFile); return file.fileAnalysis!.resolvedQueries.values.single; } Future analyzeQuery(String sql) async { return analyzeSingleQueryInDriftFile('a: $sql'); } TypeMatcher scalarColumn(String name) => isA().having((e) => e.name, 'name', name); TypeMatcher structedFromNested( TypeMatcher nestedType) => isA() .having((e) => e.nestedType, 'nestedType', nestedType); TypeMatcher nestedListQuery( String columnName, TypeMatcher nestedType) { return isA() .having((e) => e.column.filedName(), 'column', columnName) .having((e) => e.nestedType, 'nestedType', nestedType); } TypeMatcher isExistingRowType({ String? type, String? constructorName, Object? singleValue, Object? positional, Object? named, Object? isRecord, }) { var matcher = isA(); if (type != null) { matcher = matcher.having((e) => e.rowType.toString(), 'rowType', type); } if (constructorName != null) { matcher = matcher.having( (e) => e.constructorName, 'constructorName', constructorName); } if (singleValue != null) { matcher = matcher.having((e) => e.singleValue, 'singleValue', singleValue); } if (positional != null) { matcher = matcher.having( (e) => e.positionalArguments, 'positionalArguments', positional); } if (named != null) { matcher = matcher.having((e) => e.namedArguments, 'namedArguments', named); } if (isRecord != null) { matcher = matcher.having((e) => e.isRecord, 'isRecord', isRecord); } return matcher; }