Skip to content

Commit

Permalink
g.extension: show fatal message if installed Add-On doesn't exists in…
Browse files Browse the repository at this point in the history
… the repository (#2916)
  • Loading branch information
tmszi committed Apr 14, 2023
1 parent a7ed30c commit 49f5cad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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(
", ".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()

0 comments on commit 49f5cad

Please sign in to comment.