platform/angel_orm_generator/test/common.dart

24 lines
900 B
Dart
Raw Normal View History

2017-07-09 16:53:35 +00:00
import 'dart:async';
import 'dart:io';
import 'package:postgres/postgres.dart';
Future<PostgreSQLConnection> connectToPostgres() async {
var conn = new PostgreSQLConnection('127.0.0.1', 5432, 'angel_orm_test',
username: Platform.environment['POSTGRES_USERNAME'] ?? 'postgres',
password: Platform.environment['POSTGRES_PASSWORD'] ?? 'password');
await conn.open();
var query = await new File('test/models/car.up.g.sql').readAsString();
await conn.execute(query);
2017-07-15 15:11:57 +00:00
query = await new File('test/models/author.up.g.sql').readAsString();
await conn.execute(query);
query = await new File('test/models/book.up.g.sql').readAsString();
await conn.execute(query);
query = await new File('test/models/role.up.g.sql').readAsString();
await conn.execute(query);
query = await new File('test/models/user.up.g.sql').readAsString();
await conn.execute(query);
2017-07-09 16:53:35 +00:00
return conn;
}