Fix broken tests

This commit is contained in:
Daniel Berkompas 2017-11-03 13:43:56 -07:00
parent 383982ac88
commit d38d224873
3 changed files with 7 additions and 11 deletions

8
bin/ci
View file

@ -5,14 +5,6 @@
# This script contains all the test commands for this app, which will be run
# on the continuous integration server.
if [ $CI ]; then
# Setup steps to ensure fast builds on Semaphore CI
export MIX_HOME=$SEMAPHORE_CACHE_DIR
mkdir -p $SEMAPHORE_CACHE_DIR/{_build,deps}
ln -s $SEMAPHORE_CACHE_DIR/deps $SEMAPHORE_PROJECT_DIR/deps
ln -s $SEMAPHORE_CACHE_DIR/_build $SEMAPHORE_PROJECT_DIR/_build
fi
MIX_ENV=test mix compile --warnings-as-errors --force || { echo 'Please fix all compiler warnings.'; exit 1; }
MIX_ENV=test mix docs || { echo 'Elixir HTML docs were not generated!'; exit 1; }
MIX_ENV=test mix dialyze || { echo 'Dialyzer checks failed.'; exit 1; }

View file

@ -182,8 +182,8 @@ defmodule Elasticsearch do
with {:ok, indexes} <- get("/_cat/indices?format=json") do
indexes =
indexes
|> Stream.map(&(&1["index"]))
|> Stream.filter(&String.starts_with?(&1, prefix))
|> Enum.map(&(&1["index"]))
|> Enum.filter(&String.starts_with?(&1, prefix))
|> Enum.sort()
{:ok, indexes}

View file

@ -38,10 +38,14 @@ defmodule Elasticsearch.API.HTTP do
@doc false
def process_response_body(body) do
if body =~ "{" do
if json?(body) do
Poison.decode!(body)
else
body
end
end
defp json?(str) do
str =~ ~r/^\{/ || str =~ ~r/^\[/
end
end