Skip to content

Commit

Permalink
Add new test cases based on regex modification.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelovilla committed Feb 21, 2024
1 parent 5371bcd commit c16b094
Showing 1 changed file with 36 additions and 12 deletions.
48 changes: 36 additions & 12 deletions tests/tests_unit/test_cli_init_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,45 @@ def test_cli_init_error_repository_missing_env(monkeypatch: pytest.MonkeyPatch):
assert tmp_file.exists() is False


def test_cli_init_error_invalid_repo(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setenv("GITHUB_USERNAME", TEST_GITHUB_USERNAME)
monkeypatch.setenv("GITHUB_TOKEN", TEST_GITHUB_TOKEN)
@pytest.mark.parametrize(
"url",
[
"https://github.com/user/repository",
"https://gitlab.com/user/repository/",
],
)
def test_cli_init_valid_repo(url):
app = create_cli()

args = ["init", "local", "--project-name", "test", "--repository", url]

with tempfile.TemporaryDirectory() as tmp:
tmp_file = Path(tmp).resolve() / "nebari-config.yaml"
assert tmp_file.exists() is False

result = runner.invoke(app, args + ["--output", tmp_file.resolve()])

assert 0 == result.exit_code
assert not result.exception
assert tmp_file.exists() is True


@pytest.mark.parametrize(
"url",
[
"https://github.com",
"https://gitlab.com/user/",
"https://gitlab.com/user",
"http://github.com/user/",
"gitlab.com/user/",
"github.com",
"https://notgithub.com/user/repository",
],
)
def test_cli_init_error_invalid_repo(url):
app = create_cli()

args = [
"init",
"local",
"--project-name",
"test",
"--repository-auto-provision",
"--repository",
"https://notgithub.com",
]
args = ["init", "local", "--project-name", "test", "--repository", url]

with tempfile.TemporaryDirectory() as tmp:
tmp_file = Path(tmp).resolve() / "nebari-config.yaml"
Expand Down

0 comments on commit c16b094

Please sign in to comment.