Skip to content

Commit

Permalink
Add integration test for local code migrator
Browse files Browse the repository at this point in the history
  • Loading branch information
JCZuurmond committed Jan 14, 2025
1 parent 7f7b525 commit 6acd6aa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/integration/source_code/linters/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,19 @@ def test_local_code_migrator_fixes_ucx(simple_ctx, ucx_source_path) -> None:
has_code_changes = migrator.apply(ucx_source_path)

assert not has_code_changes


def test_local_code_migrator_fixes_migrated_hive_metastore_table(simple_ctx, tmp_path) -> None:
# TODO: Is this a unit or integration test?
path = tmp_path / "read_table.py"
path.write_text("df = spark.read.table('hive_metastore.schema.table')")

session_state = CurrentSessionState() # No need to connect
index = TableMigrationIndex([TableMigrationStatus("schema", "table", "catalog", "schema", "table")])
linter_context = LinterContext(index, session_state)
migrator = LocalCodeMigrator(lambda: linter_context)

has_code_changes = migrator.apply(path)

assert has_code_changes, "Expected the Hive metastore table to be rewritten to a UC table"
assert "catalog" in path.read_text()

0 comments on commit 6acd6aa

Please sign in to comment.