From 2dcdf738ce84c56155359b09fcfc7ccefaa712c8 Mon Sep 17 00:00:00 2001 From: DavHau Date: Mon, 13 Nov 2023 21:56:02 +0700 Subject: [PATCH] api/machines: add test ensuring empty config is valid --- pkgs/clan-cli/tests/test_machines_api.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkgs/clan-cli/tests/test_machines_api.py b/pkgs/clan-cli/tests/test_machines_api.py index c2f76f4f9..ce17d3815 100644 --- a/pkgs/clan-cli/tests/test_machines_api.py +++ b/pkgs/clan-cli/tests/test_machines_api.py @@ -25,11 +25,11 @@ def test_schema_errors(api: TestClient, test_flake_with_core: FlakeForTest) -> N # make sure that eval errors do not raise an internal server error response = api.put( f"/api/{test_flake_with_core.name}/schema", - json={"imports": ["some-inavlid-import"]}, + json={"imports": ["some-invalid-import"]}, ) assert response.status_code == 422 assert ( - "error: string 'some-inavlid-import' doesn't represent an absolute path" + "error: string 'some-invalid-import' doesn't represent an absolute path" in response.json()["detail"][0]["msg"] ) @@ -74,6 +74,21 @@ def test_verify_config_without_machine( assert response.json() == {"success": True, "error": None} +@pytest.mark.with_core +def test_ensure_empty_config_is_valid( + api: TestClient, test_flake_with_core: FlakeForTest +) -> None: + response = api.put( + f"/api/{test_flake_with_core.name}/machines/test/config", + json=dict(), + ) + assert response.status_code == 200 + + response = api.get(f"/api/{test_flake_with_core.name}/machines/test/verify") + assert response.status_code == 200 + assert response.json() == {"success": True, "error": None} + + @pytest.mark.with_core def test_configure_machine(api: TestClient, test_flake_with_core: FlakeForTest) -> None: # ensure error 404 if machine does not exist when accessing the config