diff --git a/data/oci_model/package.py b/data/oci_model/package.py index c91affe7a..61eae8e20 100644 --- a/data/oci_model/package.py +++ b/data/oci_model/package.py @@ -16,6 +16,9 @@ def list_packages_query(namespace=None, media_type=None, search_query=None, user username=username, search_fields=fields, limit=50) + if not repositories: + return [] + repo_query = (Repository .select(Repository, Namespace.username) .join(Namespace, on=(Repository.namespace_user == Namespace.id)) diff --git a/endpoints/appr/test/test_api.py b/endpoints/appr/test/test_api.py index 853d7f77f..722587b87 100644 --- a/endpoints/appr/test/test_api.py +++ b/endpoints/appr/test/test_api.py @@ -91,6 +91,18 @@ class TestServerQuayDB(BaseTestServer): """ TODO: search cross namespace and package name """ BaseTestServer.test_search_package_match(self, db_with_data1, client) + def test_list_search_package_match(self, db_with_data1, client): + url = self._url_for("api/v1/packages") + res = self.Client(client, self.headers()).get(url, params={'query': 'rocketchat'}) + assert res.status_code == 200 + assert len(self.json(res)) == 1 + + def test_list_search_package_no_match(self, db_with_data1, client): + url = self._url_for("api/v1/packages") + res = self.Client(client, self.headers()).get(url, params={'query': 'toto'}) + assert res.status_code == 200 + assert len(self.json(res)) == 0 + @pytest.mark.xfail def test_push_package_already_exists_force(self, db_with_data1, package_b64blob, client): """ No force push implemented """