Also run tests for moor on chrome and firefox

This commit is contained in:
Simon Binder 2020-01-27 16:58:48 +01:00
parent 80a10c73d8
commit d4cf9c26eb
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
9 changed files with 76 additions and 35 deletions

View File

@ -1,2 +1,12 @@
tags:
integration:
integration:
platforms:
- vm
presets:
# Only run on browsers when requested. In CI, we only test on browsers when the VM tests went through
browsers:
platforms:
- chrome
- firefox

View File

@ -90,6 +90,8 @@ void main() {
verifyNever(executor.runBatched(any));
verify(executor.transactions.runBatched(any));
}, onPlatform: const {
'js': [Skip('Blocked by https://github.com/dart-lang/mockito/issues/198')]
});
test('updates stream queries', () async {

View File

@ -82,5 +82,7 @@ void main() {
// regression test for https://github.com/simolus3/moor/issues/199 - the
// mock will throw when used before opening
expect(db.customStatement('UPDATE tbl SET a = b'), completes);
}, onPlatform: const {
'js': [Skip('Blocked by https://github.com/dart-lang/mockito/issues/198')]
});
}

View File

@ -1190,7 +1190,7 @@ abstract class _$CustomTablesDb extends GeneratedDatabase {
Selectable<TableValuedResult> tableValued() {
return customSelectQuery(
'SELECT\n "key", "value"\n FROM config, json_each(config.config_value)\n WHERE json_valid(config_value)',
'SELECT "key", "value"\n FROM config, json_each(config.config_value)\n WHERE json_valid(config_value)',
variables: [],
readsFrom: {config}).map(_rowToTableValuedResult);
}

View File

@ -1,4 +1,5 @@
@Tags(['integration'])
@TestOn('vm')
import 'package:moor_ffi/moor_ffi.dart';
import 'package:test/test.dart';

View File

@ -0,0 +1,36 @@
@Tags(['integration'])
@TestOn('vm')
import 'dart:convert';
import 'package:moor/moor.dart';
import 'package:moor/extensions/json1.dart';
import 'package:moor_ffi/moor_ffi.dart';
import 'package:test/test.dart';
import '../data/tables/todos.dart';
void main() {
test('json1 integration test', () async {
final db = TodoDb(VmDatabase.memory());
const jsonObject = {
'foo': 'bar',
'array': [
'one',
'two',
'three',
],
};
await db
.into(db.pureDefaults)
.insert(PureDefaultsCompanion(txt: Value(json.encode(jsonObject))));
final arrayLengthExpr = db.pureDefaults.txt.jsonArrayLength(r'$.array');
final query = db.select(db.pureDefaults).addColumns([arrayLengthExpr]);
query.where(db.pureDefaults.txt
.jsonExtract(r'$.foo')
.equalsExp(Variable.withString('bar')));
final resultRow = await query.getSingle();
expect(resultRow.read(arrayLengthExpr), 3);
}, tags: const ['integration']);
}

View File

@ -1,11 +1,7 @@
import 'dart:convert';
import 'package:moor/moor.dart';
import 'package:moor/extensions/json1.dart';
import 'package:moor_ffi/moor_ffi.dart';
import 'package:test/test.dart';
import '../data/tables/todos.dart';
import '../data/utils/expect_generated.dart';
void main() {
@ -23,28 +19,4 @@ void main() {
generates('json_extract(col, ?)', [r'$.c']),
);
});
test('json1 integration test', () async {
final db = TodoDb(VmDatabase.memory());
const jsonObject = {
'foo': 'bar',
'array': [
'one',
'two',
'three',
],
};
await db
.into(db.pureDefaults)
.insert(PureDefaultsCompanion(txt: Value(json.encode(jsonObject))));
final arrayLengthExpr = db.pureDefaults.txt.jsonArrayLength(r'$.array');
final query = db.select(db.pureDefaults).addColumns([arrayLengthExpr]);
query.where(db.pureDefaults.txt
.jsonExtract(r'$.foo')
.equalsExp(Variable.withString('bar')));
final resultRow = await query.getSingle();
expect(resultRow.read(arrayLengthExpr), 3);
}, tags: const ['integration']);
}

View File

@ -1,6 +1,15 @@
FROM google/dart:latest
FROM ubuntu:rolling
RUN apt-get update && apt-get install -y -q libsqlite3-dev
RUN apt-get update && apt-get install -y --no-install-recommends apt-transport-https wget gnupg2 ca-certificates
# Setup for Dart
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list
# Setup for Google Chrome
RUN echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list
RUN apt-get update && apt-get install -y --no-install-recommends -q libsqlite3-dev google-chrome-stable firefox dart
# We ocassionally have to change this file to manually trigger rebuilds in the CI. Particularly, after a new Dart SDK
# version is out.

View File

@ -1,5 +1,14 @@
#!/usr/bin/env bash
cd moor
pub run build_runner test --delete-conflicting-outputs
pub run test --coverage=coverage
EXIT_CODE=0
cd moor || exit 1
pub run build_runner build --delete-conflicting-outputs
pub run test --coverage=coverage || EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]
then pub run test -P browsers || EXIT_CODE=$?
fi
exit $EXIT_CODE