Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

g.extension: show fatal message if installed Add-On doesn't exists in the repository #2916

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions scripts/g.extension/g.extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,16 @@ def _get_addons_list(self):
)
return addons_dict

def _addon_exists(self, addon_list):
if not [self.addons[addon] for addon in addon_list if addon in self.addons]:
gs.fatal(
_("No AddOn named <{}> found in the repository.").format(
tmszi marked this conversation as resolved.
Show resolved Hide resolved
", ".join(addon_list)
)
)

def fetch_addons(self, addon_list, all_addons=False):
self._addon_exists(addon_list)
if addon_list:
if self.git_version >= 2.25 and not all_addons:
gs.call(
Expand Down
9 changes: 9 additions & 0 deletions scripts/g.extension/testsuite/test_addons_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from pathlib import Path

from grass.gunittest.case import TestCase
from grass.gunittest.gmodules import SimpleModule
from grass.gunittest.main import test
from grass.gunittest.utils import silent_rmtree

Expand Down Expand Up @@ -155,6 +156,14 @@ def test_github_install_official_multimodule(self):
if file.suffix != ".html" and file.suffix != ".py":
self.assertModule(str(file), help=True)

def test_github_install_official_non_exists_module(self):
"""Test installing non exists extension from official addons repository"""
extension = "non_exists_extension"
gextension = SimpleModule("g.extension", extension=extension)
self.assertModuleFail(gextension)
self.assertTrue(gextension.outputs.stderr)
self.assertIn(extension, gextension.outputs.stderr)


if __name__ == "__main__":
test()