cyberhybridhub/server/test/integration/migration_test.dart

55 lines
1.3 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@Tags(['integration', 'postgres'])
library;
import 'package:postgres/postgres.dart';
import 'package:test/test.dart';
import '../helpers/test_db.dart';
void main() {
TestDb? testDb;
setUpAll(() async {
testDb = await TestDb.open();
});
tearDownAll(() async {
await testDb?.close();
});
test('migrations 001004 apply on cyberhybridhub_test', () async {
if (testDb == null) {
markTestSkipped('Set DATABASE_URL or TEST_DATABASE_URL for integration tests');
return;
}
final Connection connection = testDb!.connection;
final Result tables = await connection.execute(
'''
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name IN (
'users',
'questions',
'market_data_snapshots',
'trading_config_templates',
'user_trading_config',
'user_trading_state',
'trade_orders'
)
ORDER BY table_name
''',
);
expect(tables.map((ResultRow r) => r[0]), hasLength(7));
final Result template = await connection.execute(
Sql.named(
'SELECT name FROM trading_config_templates WHERE name = @name',
),
parameters: <String, dynamic>{'name': 'default_paper_watchlist'},
);
expect(template, isNotEmpty);
});
}