Skip to content

Commit c634d42

Browse files
authored
Merge pull request ckan#8148 from EricSoroos/search_rebuild_message
Add an error notification when rebuilding the search index for a package that can't be found
2 parents 7ca456d + 84bb65f commit c634d42

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

changes/8148.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add error notification when rebuilding the search index via the cli when the requested package can't be found.

ckan/cli/search_index.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ def rebuild(
4848
defer_commit=(not commit_each),
4949
quiet=quiet and not verbose,
5050
clear=clear)
51+
except logic.NotFound:
52+
error_shout("Couldn't find package %s" % package_id)
5153
except Exception as e:
5254
error_shout(e)
5355
if not commit_each:

ckan/tests/cli/test_search_index.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,9 @@ def test_test_main_operations(self, cli):
172172
assert not result.exit_code, result.output
173173
search_result = helpers.call_action(u'package_search', q=u"package")
174174
assert search_result[u'count'] == 2
175+
176+
def test_rebuild_invalid_dataset(self, cli):
177+
# attempt to index package that doesn't exist
178+
result = cli.invoke(ckan, [u'search-index', u'rebuild', u'invalid-dataset'])
179+
assert not result.exit_code, result.output
180+
assert "Couldn't find" in result.output

0 commit comments

Comments
 (0)