Skip to content

Commit 4e31485

Browse files
committed
Test invalid project name
Signed-off-by: ted chang <htchang@us.ibm.com>
1 parent 9e74887 commit 4e31485

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

‎sdk/python/tests/test_init.py‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import tempfile
22
from datetime import datetime, timedelta
33
from pathlib import Path
4+
from textwrap import dedent
45

56
from tests.cli_utils import CliRunner
67

@@ -25,3 +26,43 @@ def test_repo_init() -> None:
2526
["materialize", start_date.isoformat(), end_date.isoformat()], cwd=repo_path
2627
)
2728
assert result.returncode == 0
29+
30+
31+
def test_repo_init_with_underscore_in_project_name() -> None:
32+
"""
33+
Test `feast init` with underscore in the project name
34+
"""
35+
with tempfile.TemporaryDirectory() as temp_dir:
36+
temp_path = Path(temp_dir)
37+
runner = CliRunner()
38+
39+
# `feast init` should fail with repo names start with underscore
40+
invalid_repo_names = ["_test", "_test_1"]
41+
for repo_name in invalid_repo_names:
42+
result = runner.run(["init", repo_name], cwd=temp_path)
43+
assert result.returncode != 0
44+
45+
# `feast init` should succeed with underscore in repo name
46+
valid_repo_names = ["test_1"]
47+
for repo_name in valid_repo_names:
48+
result = runner.run(["init", repo_name], cwd=temp_path)
49+
assert result.returncode == 0
50+
51+
# `feast apply` should fail with underscore in project name
52+
project_name = "test_1"
53+
repo_dir = temp_path / project_name
54+
data_dir = repo_dir / "data"
55+
repo_config = repo_dir / "feature_store.yaml"
56+
repo_config.write_text(
57+
dedent(
58+
f"""
59+
project: __foo
60+
registry: {data_dir / "registry.db"}
61+
provider: local
62+
online_store:
63+
path: {data_dir / "online_store.db"}
64+
"""
65+
)
66+
)
67+
result = runner.run(["apply"], cwd=repo_dir)
68+
assert result.returncode != 0

0 commit comments

Comments
 (0)