mirror of https://github.com/AMT-Cheif/drift.git
Format, improve travis testing
This commit is contained in:
parent
e4f733119d
commit
700a21d29e
|
@ -6,7 +6,7 @@
|
|||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/analyzer-0.34.3/lib" />
|
||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/analyzer-0.35.0/lib" />
|
||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/analyzer-0.35.1/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
|
@ -191,7 +191,7 @@
|
|||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/front_end-0.1.9+1/lib" />
|
||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/front_end-0.1.10/lib" />
|
||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/front_end-0.1.11/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
|
@ -269,7 +269,7 @@
|
|||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/kernel-0.3.9+1/lib" />
|
||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/kernel-0.3.10/lib" />
|
||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/kernel-0.3.11/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
|
@ -486,7 +486,6 @@
|
|||
<entry key="stream_transform">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stream_transform-0.0.14+1/lib" />
|
||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stream_transform-0.0.15/lib" />
|
||||
</list>
|
||||
</value>
|
||||
|
@ -597,7 +596,7 @@
|
|||
</properties>
|
||||
<CLASSES>
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/analyzer-0.34.3/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/analyzer-0.35.0/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/analyzer-0.35.1/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/analyzer_plugin-0.0.1-alpha.6/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/args-1.5.1/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/async-2.0.8/lib" />
|
||||
|
@ -625,7 +624,7 @@
|
|||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/csslib-0.14.6/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/dart_style-1.2.3/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/fixnum-0.10.9/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/front_end-0.1.10/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/front_end-0.1.11/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/front_end-0.1.9+1/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/glob-1.1.7/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/graphs-0.2.0/lib" />
|
||||
|
@ -637,7 +636,7 @@
|
|||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/js-0.6.1+1/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/json_annotation-2.0.0/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/json_rpc_2-2.0.9/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/kernel-0.3.10/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/kernel-0.3.11/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/kernel-0.3.9+1/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/logging-0.11.3+2/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.3+1/lib" />
|
||||
|
@ -666,7 +665,6 @@
|
|||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/source_span-1.5.4/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stream_channel-1.6.8/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stream_transform-0.0.14+1/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stream_transform-0.0.15/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.4/lib" />
|
||||
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib" />
|
||||
|
|
|
@ -7,7 +7,7 @@ env:
|
|||
- PKG="sally"
|
||||
- PKG="sally_generator"
|
||||
|
||||
script: ./tool/travis.sh dartfmt dartanalyzer test
|
||||
script: ./tool/mono_repo_wrapper.sh
|
||||
|
||||
# Only building master means that we don't run two builds for each pull request.
|
||||
branches:
|
||||
|
|
|
@ -14,7 +14,8 @@ class StreamQueryStore {
|
|||
}
|
||||
|
||||
Future<void> handleTableUpdates(String table) async {
|
||||
final affectedStreams = _activeStreams.where((stream) => stream.isAffectedByTableChange(table));
|
||||
final affectedStreams =
|
||||
_activeStreams.where((stream) => stream.isAffectedByTableChange(table));
|
||||
|
||||
for (var stream in affectedStreams) {
|
||||
await stream.fetchAndEmitData();
|
||||
|
|
|
@ -16,7 +16,8 @@ class DeleteStatement<UserTable> extends Query<UserTable, dynamic> {
|
|||
Future<int> go() async {
|
||||
final ctx = constructQuery();
|
||||
|
||||
final rows = await ctx.database.executor.runDelete(ctx.sql, ctx.boundVariables);
|
||||
final rows =
|
||||
await ctx.database.executor.runDelete(ctx.sql, ctx.boundVariables);
|
||||
|
||||
if (rows > 0) {
|
||||
database.markTableUpdated(table.$tableName);
|
||||
|
|
|
@ -12,7 +12,8 @@ class InsertStatement<DataClass> {
|
|||
|
||||
Future<void> insert(DataClass entity) async {
|
||||
if (!table.validateIntegrity(entity, true)) {
|
||||
throw InvalidDataException('Invalid data: $entity cannot be written into ${table.$tableName}');
|
||||
throw InvalidDataException(
|
||||
'Invalid data: $entity cannot be written into ${table.$tableName}');
|
||||
}
|
||||
|
||||
final map = table.entityToSql(entity)
|
||||
|
|
|
@ -39,11 +39,13 @@ class UpdateStatement<T, D> extends Query<T, D> {
|
|||
Future<int> write(D entity) async {
|
||||
_updateReference = entity;
|
||||
if (!table.validateIntegrity(_updateReference, false)) {
|
||||
throw InvalidDataException('Invalid data: $entity cannot be written into ${table.$tableName}');
|
||||
throw InvalidDataException(
|
||||
'Invalid data: $entity cannot be written into ${table.$tableName}');
|
||||
}
|
||||
|
||||
final ctx = constructQuery();
|
||||
final rows = await ctx.database.executor.runUpdate(ctx.sql, ctx.boundVariables);
|
||||
final rows =
|
||||
await ctx.database.executor.runUpdate(ctx.sql, ctx.boundVariables);
|
||||
|
||||
if (rows > 0) {
|
||||
database.markTableUpdated(table.$tableName);
|
||||
|
|
|
@ -75,15 +75,11 @@ class GeneratedTextColumn extends GeneratedColumn<String, StringType>
|
|||
if (value == null) return nullOk;
|
||||
|
||||
final length = value.length;
|
||||
if (minTextLength != null && minTextLength > length)
|
||||
return false;
|
||||
if (maxTextLength != null && maxTextLength < length)
|
||||
return false;
|
||||
if (minTextLength != null && minTextLength > length) return false;
|
||||
if (maxTextLength != null && maxTextLength < length) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class GeneratedBoolColumn extends GeneratedColumn<bool, BoolType>
|
||||
|
|
|
@ -17,7 +17,7 @@ abstract class TableInfo<TableDsl, DataClass> {
|
|||
/// that it respects all constraints (nullability, text length, etc.).
|
||||
/// During insertion mode, fields that have a default value or are
|
||||
/// auto-incrementing are allowed to be null as they will be set by sqlite.
|
||||
bool validateIntegrity(DataClass instance, bool isInserting) => null;
|
||||
bool validateIntegrity(DataClass instance, bool isInserting);
|
||||
|
||||
/// Maps the given data class into a map that can be inserted into sql. The
|
||||
/// keys should represent the column name in sql, the values the corresponding
|
||||
|
|
|
@ -3,7 +3,7 @@ dart:
|
|||
|
||||
stages:
|
||||
- analyze:
|
||||
- dartanalyzer
|
||||
- dartanalyzer: --fatal-infos --fatal-warnings .
|
||||
- dartfmt
|
||||
- unit_test:
|
||||
- test
|
||||
- command: pub run build_runner test
|
|
@ -14,5 +14,6 @@ dev_dependencies:
|
|||
sally_generator:
|
||||
path: ../sally_generator
|
||||
build_runner: ^1.2.6
|
||||
build_test: ^0.10.6
|
||||
test: ^1.5.3
|
||||
mockito: ^4.0.0
|
||||
|
|
|
@ -53,12 +53,7 @@ void main() {
|
|||
group('SELECT results are parsed', () {
|
||||
test('when all fields are non-null', () {
|
||||
final data = [
|
||||
{
|
||||
'id': 10,
|
||||
'title': 'A todo title',
|
||||
'content': 'Content',
|
||||
'category': 3
|
||||
}
|
||||
{'id': 10, 'title': 'A todo title', 'content': 'Content', 'category': 3}
|
||||
];
|
||||
final resolved = TodoEntry(
|
||||
id: 10,
|
||||
|
|
|
@ -4,7 +4,6 @@ part 'todos.g.dart';
|
|||
|
||||
@DataClassName('TodoEntry')
|
||||
class TodosTable extends Table {
|
||||
|
||||
@override
|
||||
String get tableName => 'todos';
|
||||
|
||||
|
@ -13,7 +12,6 @@ class TodosTable extends Table {
|
|||
TextColumn get content => text()();
|
||||
|
||||
IntColumn get category => integer().nullable()();
|
||||
|
||||
}
|
||||
|
||||
class Users extends Table {
|
||||
|
@ -24,10 +22,8 @@ class Users extends Table {
|
|||
|
||||
@DataClassName('Category')
|
||||
class Categories extends Table {
|
||||
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
TextColumn get description => text().named('desc')();
|
||||
|
||||
}
|
||||
|
||||
@UseSally(tables: [TodosTable, Categories, Users])
|
||||
|
@ -39,5 +35,4 @@ class TodoDb extends _$TodoDb {
|
|||
|
||||
@override
|
||||
int get schemaVersion => 1;
|
||||
|
||||
}
|
|
@ -5,14 +5,12 @@ import 'package:sally/src/runtime/executor/stream_queries.dart';
|
|||
export 'package:mockito/mockito.dart';
|
||||
|
||||
class MockExecutor extends Mock implements QueryExecutor {
|
||||
|
||||
MockExecutor() {
|
||||
when(runSelect(any, any)).thenAnswer((_) => Future.value([]));
|
||||
when(runUpdate(any, any)).thenAnswer((_) => Future.value(0));
|
||||
when(runDelete(any, any)).thenAnswer((_) => Future.value(0));
|
||||
when(runInsert(any, any)).thenAnswer((_) => Future.value(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MockStreamQueries extends Mock implements StreamQueryStore {}
|
||||
|
|
|
@ -43,10 +43,13 @@ class SpecifiedColumn {
|
|||
/// as getter name in the TableInfo class (as it needs to override the field)
|
||||
/// and in the generated data class that will be generated for each table.
|
||||
final String dartGetterName;
|
||||
|
||||
/// The sql type of this column
|
||||
final ColumnType type;
|
||||
|
||||
/// The name of this column, as chosen by the user
|
||||
final ColumnName name;
|
||||
|
||||
/// Whether the user has explicitly declared this column to be nullable, the
|
||||
/// default is false
|
||||
final bool nullable;
|
||||
|
|
|
@ -15,6 +15,7 @@ class TableParser extends ParserBase {
|
|||
|
||||
SpecifiedTable parse(ClassElement element) {
|
||||
final sqlName = _parseTableName(element);
|
||||
if (sqlName == null) return null;
|
||||
|
||||
return SpecifiedTable(
|
||||
fromClass: element,
|
||||
|
|
|
@ -141,7 +141,6 @@ const sqliteKeywords = [
|
|||
bool isSqliteKeyword(String s) => sqliteKeywords.contains(s.toUpperCase());
|
||||
|
||||
String escapeIfNeeded(String s) {
|
||||
if (isSqliteKeyword(s))
|
||||
return '`$s`';
|
||||
if (isSqliteKeyword(s)) return '`$s`';
|
||||
return s;
|
||||
}
|
|
@ -76,8 +76,8 @@ class TableWriter {
|
|||
final resolver = '${ReCase(usedType).camelCase}Type';
|
||||
dartTypeToResolver[usedType] = resolver;
|
||||
|
||||
buffer
|
||||
.write('final $resolver = _db.typeSystem.forDartType<$usedType>();\n');
|
||||
buffer.write(
|
||||
'final $resolver = _db.typeSystem.forDartType<$usedType>();\n');
|
||||
}
|
||||
|
||||
// finally, the mighty constructor invocation:
|
||||
|
@ -146,7 +146,8 @@ class TableWriter {
|
|||
void _writeValidityCheckMethod(StringBuffer buffer) {
|
||||
final dataClass = table.dartTypeName;
|
||||
|
||||
buffer.write('@override\nbool validateIntegrity($dataClass instance, bool isInserting) => ');
|
||||
buffer.write(
|
||||
'@override\nbool validateIntegrity($dataClass instance, bool isInserting) => ');
|
||||
|
||||
final validationCode = table.columns.map((column) {
|
||||
final getterName = column.dartGetterName;
|
||||
|
|
|
@ -3,7 +3,7 @@ dart:
|
|||
|
||||
stages:
|
||||
- analyze:
|
||||
- dartanalyzer
|
||||
- dartanalyzer: --fatal-infos --fatal-warnings .
|
||||
- dartfmt
|
||||
- unit_test:
|
||||
- test
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
case $PKG in
|
||||
sally_generator)
|
||||
./tool/travis.sh dartfmt dartanalyzer test
|
||||
;;
|
||||
sally)
|
||||
./tool/travis.sh dartfmt dartanalyzer command
|
||||
;;
|
||||
esac
|
|
@ -19,10 +19,15 @@ EXIT_CODE=0
|
|||
while (( "$#" )); do
|
||||
TASK=$1
|
||||
case $TASK in
|
||||
command) echo
|
||||
echo -e '\033[1mTASK: command\033[22m'
|
||||
echo -e 'pub run build_runner test'
|
||||
pub run build_runner test || EXIT_CODE=$?
|
||||
;;
|
||||
dartanalyzer) echo
|
||||
echo -e '\033[1mTASK: dartanalyzer\033[22m'
|
||||
echo -e 'dartanalyzer .'
|
||||
dartanalyzer . || EXIT_CODE=$?
|
||||
echo -e 'dartanalyzer --fatal-infos --fatal-warnings .'
|
||||
dartanalyzer --fatal-infos --fatal-warnings . || EXIT_CODE=$?
|
||||
;;
|
||||
dartfmt) echo
|
||||
echo -e '\033[1mTASK: dartfmt\033[22m'
|
||||
|
|
Loading…
Reference in New Issue