Skip to content

Commit

Permalink
add alias set test too
Browse files Browse the repository at this point in the history
  • Loading branch information
chamini2 committed Dec 13, 2023
1 parent af06124 commit ba504dc
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions projects/fal/tests/test_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def addition_app(input: Input) -> Output:
return Output(result=input.lhs + input.rhs)


@pytest.fixture(scope="function")
@pytest.fixture(scope="module")
def aliased_app() -> Generator[tuple[str, str], None, None]:
# Create a temporary app, register it, and return the ID of it.

Expand All @@ -48,6 +48,7 @@ def aliased_app() -> Generator[tuple[str, str], None, None]:
options=addition_app.options,
# random enough
application_name=app_alias,
application_auth_mode="private",
)
yield app_revision, app_alias # type: ignore

Expand Down Expand Up @@ -170,16 +171,31 @@ def test_app_update_app(aliased_app: tuple[str, str]):
assert res.max_multiplexing == new_max_multiplexing


def test_app_delete_alias(aliased_app: tuple[str, str]):
def test_app_set_delete_alias(aliased_app: tuple[str, str]):
app_revision, app_alias = aliased_app

host: api.FalServerlessHost = addition_app.host # type: ignore

with host._connection as client:
# Get the registered values
res = client.list_aliases()
found = next(filter(lambda alias: alias.alias == app_alias, res), None)
assert found, f"Could not find app {app_alias} in {res}"
assert found.revision == app_revision
assert found.auth_mode == "private"

new_app_alias = f"{app_alias}-new"
with host._connection as client:
# Get the registered values
res = client.create_alias(new_app_alias, app_revision, "public")

with host._connection as client:
# Get the registered values
res = client.list_aliases()
found = next(filter(lambda alias: alias.alias == new_app_alias, res), None)
assert found, f"Could not find app {app_alias} in {res}"
assert found.revision == app_revision
assert found.auth_mode == "public"

with host._connection as client:
res = client.delete_alias(alias=app_alias)
Expand Down

0 comments on commit ba504dc

Please sign in to comment.