|
12 | 12 |
|
13 | 13 | sys.path.insert(0, str(Path(__file__).parent.parent / "src")) |
14 | 14 |
|
15 | | -from schemaforge.cli import main |
| 15 | +from schemaforge.cli import _detect_format, main |
16 | 16 |
|
17 | 17 | # ── Helpers ── |
18 | 18 |
|
@@ -460,3 +460,47 @@ def test_check_help(self): |
460 | 460 | assert result.exit_code == 0 |
461 | 461 | assert "Usage:" in result.output |
462 | 462 | assert "--dir" in result.output |
| 463 | + |
| 464 | + |
| 465 | +# ═══════════════════════════════════════════════════════════════ |
| 466 | +# _detect_format |
| 467 | +# ═══════════════════════════════════════════════════════════════ |
| 468 | + |
| 469 | +class TestDetectFormat: |
| 470 | + """Tests for the private _detect_format helper.""" |
| 471 | + |
| 472 | + def test_sql_extension(self): |
| 473 | + assert _detect_format("schema.sql") == "sql" |
| 474 | + |
| 475 | + def test_prisma_extension(self): |
| 476 | + assert _detect_format("schema.prisma") == "prisma" |
| 477 | + |
| 478 | + def test_drizzle_ts(self): |
| 479 | + assert _detect_format("schema.ts") == "drizzle" |
| 480 | + |
| 481 | + def test_drizzle_tsx(self): |
| 482 | + assert _detect_format("schema.tsx") == "drizzle" |
| 483 | + |
| 484 | + def test_django_python(self): |
| 485 | + assert _detect_format("models.py") == "django" |
| 486 | + |
| 487 | + def test_json_schema(self): |
| 488 | + assert _detect_format("schema.json") == "json_schema" |
| 489 | + |
| 490 | + def test_graphql(self): |
| 491 | + assert _detect_format("schema.graphql") == "graphql" |
| 492 | + |
| 493 | + def test_graphql_gql(self): |
| 494 | + assert _detect_format("schema.gql") == "graphql" |
| 495 | + |
| 496 | + def test_ef_csharp(self): |
| 497 | + assert _detect_format("entities.cs") == "ef" |
| 498 | + |
| 499 | + def test_scala(self): |
| 500 | + assert _detect_format("models.scala") == "scala" |
| 501 | + |
| 502 | + def test_unknown_extension_defaults_to_sql(self): |
| 503 | + assert _detect_format("schema.txt") == "sql" |
| 504 | + |
| 505 | + def test_no_extension_defaults_to_sql(self): |
| 506 | + assert _detect_format("schema") == "sql" |
0 commit comments