import unittest
from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
MIGRATION = ROOT / "plugins" / "redmine_event_outbox" / "db" / "migrate" / "001_create_event_outbox_events.rb"


class EventOutboxMigrationTest(unittest.TestCase):
    def test_create_table_migration_is_idempotent_for_imported_dev_clone(self):
        source = MIGRATION.read_text()

        self.assertIn("table_exists?(:event_outbox_events)", source)
        self.assertIn("return if table_exists?(:event_outbox_events)", source)


if __name__ == "__main__":
    unittest.main()
