Skip to content

Commit e8cd9d7

Browse files
committed
Add test for long model and env names
1 parent 23f49ba commit e8cd9d7

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

tests/cli/test_cli.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,56 @@ def test_plan_dev_no_changes(runner, tmp_path):
553553
assert_virtual_layer_updated(result)
554554

555555

556+
def test_plan_dev_longnames(runner, tmp_path):
557+
create_example_project(tmp_path)
558+
559+
long_model_names = {
560+
"full": f"full_{'a' * 80}",
561+
"incremental": f"incremental_{'b' * 80}",
562+
"seed": f"seed_{'c' * 80}",
563+
}
564+
for model_name in long_model_names:
565+
with open(tmp_path / "models" / f"{model_name}_model.sql", "r") as f:
566+
model_text = f.read()
567+
for more_model_names in long_model_names:
568+
model_text = model_text.replace(
569+
f"sqlmesh_example.{more_model_names}_model",
570+
f"sqlmesh_example.{long_model_names[more_model_names]}_model",
571+
)
572+
with open(tmp_path / "models" / f"{model_name}_model.sql", "w") as f:
573+
f.write(model_text)
574+
575+
# Input: `y` to apply and backfill
576+
result = runner.invoke(
577+
cli,
578+
[
579+
"--log-file-dir",
580+
tmp_path,
581+
"--paths",
582+
tmp_path,
583+
"plan",
584+
"dev_butamuchlongerenvironmentname",
585+
"--skip-tests",
586+
"--no-prompts",
587+
"--auto-apply",
588+
],
589+
)
590+
assert result.exit_code == 0
591+
assert (
592+
"sqlmesh_example__dev_butamuchlongerenvironmentname.seed_cccccccccccccccccccccccc\ncccccccccccccccccccccccccccccccccccccccccccccccccccccccc_model [insert \nseed file]"
593+
in result.output
594+
)
595+
assert (
596+
"sqlmesh_example__dev_butamuchlongerenvironmentname.incremental_bbbbbbbbbbbbbbbbb\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb_model [insert "
597+
in result.output
598+
)
599+
assert (
600+
"sqlmesh_example__dev_butamuchlongerenvironmentname.full_aaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa_model [full \nrefresh"
601+
in result.output
602+
)
603+
assert_backfill_success(result)
604+
605+
556606
def test_plan_nonbreaking(runner, tmp_path):
557607
create_example_project(tmp_path)
558608
init_prod_and_backfill(runner, tmp_path)

0 commit comments

Comments
 (0)