Skip to content

Commit 72771d8

Browse files
committed
test(import[gitlab]) Verify --with-shared and --skip-group reject non-GitLab parsers
why: Flags are GitLab-only but lacked negative-case tests; a future refactor moving them to the shared parent parser would go undetected. what: - Add test_with_shared_only_on_gitlab following test_flatten_groups_only_on_gitlab pattern - Add test_skip_group_only_on_gitlab following same pattern
1 parent 8cd6f20 commit 72771d8

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

tests/cli/test_import_repos.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,44 @@ def test_flatten_groups_only_on_gitlab() -> None:
19401940
)
19411941

19421942

1943+
def test_with_shared_only_on_gitlab() -> None:
1944+
"""Test that --with-shared is only available on the gitlab subparser."""
1945+
from vcspull.cli import create_parser
1946+
1947+
parser = create_parser(return_subparsers=False)
1948+
1949+
# Should work for gitlab
1950+
args = parser.parse_args(
1951+
["import", "gitlab", "mygroup", "-w", "/tmp/repos", "--with-shared"]
1952+
)
1953+
assert args.with_shared is True
1954+
1955+
# Should fail for github
1956+
with pytest.raises(SystemExit):
1957+
parser.parse_args(
1958+
["import", "github", "myuser", "-w", "/tmp/repos", "--with-shared"]
1959+
)
1960+
1961+
1962+
def test_skip_group_only_on_gitlab() -> None:
1963+
"""Test that --skip-group is only available on the gitlab subparser."""
1964+
from vcspull.cli import create_parser
1965+
1966+
parser = create_parser(return_subparsers=False)
1967+
1968+
# Should work for gitlab
1969+
args = parser.parse_args(
1970+
["import", "gitlab", "mygroup", "-w", "/tmp/repos", "--skip-group", "bots"]
1971+
)
1972+
assert args.skip_groups == ["bots"]
1973+
1974+
# Should fail for github
1975+
with pytest.raises(SystemExit):
1976+
parser.parse_args(
1977+
["import", "github", "myuser", "-w", "/tmp/repos", "--skip-group", "bots"]
1978+
)
1979+
1980+
19431981
def test_region_only_on_codecommit() -> None:
19441982
"""Test that --region is only available on the codecommit subparser."""
19451983
from vcspull.cli import create_parser

0 commit comments

Comments
 (0)