Skip to content

Commit

Permalink
Add diagnostic message for failure during CLI search deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski committed Feb 29, 2024
1 parent 958a810 commit 3a55c2b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/mastodon/cli/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ def deploy
progress.finish

say("Indexed #{added} records, de-indexed #{removed}", :green, true)
rescue Elasticsearch::Transport::Transport::ServerError
fail_with_message <<~ERROR
There was an issue connecting to the search server. Make sure the
server is configured and running correctly, and that the environment
variable settings match what the server is expecting.
ERROR
end

private
Expand Down
11 changes: 11 additions & 0 deletions spec/lib/mastodon/cli/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@
end
end

context 'when server communication raises an error' do
let(:options) { { reset_chewy: true } }

before { allow(Chewy::Stash::Specification).to receive(:reset!).and_raise(Elasticsearch::Transport::Transport::Errors::InternalServerError) }

it 'Exits with error message' do
expect { subject }
.to raise_error(Thor::Error, /issue connecting to the search/)
end
end

context 'without options' do
before { stub_search_indexes }

Expand Down

0 comments on commit 3a55c2b

Please sign in to comment.