@Tags(['integration', 'postgres']) library; import 'package:cyberhybridhub_server/spelling/spelling_items_db.dart'; import 'package:test/test.dart'; import '../helpers/test_db.dart'; void main() { TestDb? testDb; setUpAll(() async { testDb = await TestDb.open(); }); tearDown(() async { if (testDb != null) { await testDb!.truncateTradingTables(); await testDb!.connection.execute('DELETE FROM spelling_items'); await testDb!.connection.execute('DELETE FROM spelling_words'); await testDb!.spellingItemsDb.ensureCatalogSeeded(); } }); tearDownAll(() async { await testDb?.close(); }); test('addCanonicalWord and listCanonicalWords', () async { if (testDb == null) { markTestSkipped('Set DATABASE_URL or TEST_DATABASE_URL for integration tests'); return; } final SpellingItemsDb db = testDb!.spellingItemsDb; final bool added = await db.addCanonicalWord('customword'); expect(added, isTrue); final bool duplicate = await db.addCanonicalWord('customword'); expect(duplicate, isFalse); final List words = await db.listCanonicalWords(); expect(words, contains('customword')); }); test('importCanonicalWords adds and skips duplicates', () async { if (testDb == null) { markTestSkipped('Set DATABASE_URL or TEST_DATABASE_URL for integration tests'); return; } final SpellingItemsDb db = testDb!.spellingItemsDb; final ({int added, int skipped}) result = await db.importCanonicalWords( ['alpha', 'beta', 'alpha', '', ' '], ); expect(result.added, 2); expect(result.skipped, 1); final List words = await db.listCanonicalWords(); expect(words, contains('alpha')); expect(words, contains('beta')); }); }