Skip to content

Commit

Permalink
Make index tests more robust against non-deterministic results
Browse files Browse the repository at this point in the history
The #select_value method returns a value of one randomly chosen column,
which can sometimes be a NULL value even if the row itself exist.
  • Loading branch information
grobie committed Mar 25, 2012
1 parent 50bb1bf commit 64d27ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions bin/lhm-test-all.sh
@@ -1,6 +1,10 @@
#!/bin/sh

for gemfile in gemfiles/*.gemfile; do
BUNDLE_GEMFILE=$gemfile bundle install
BUNDLE_GEMFILE=$gemfile bundle exec rake
for gemfile in gemfiles/*.gemfile
do
if !(BUNDLE_GEMFILE=$gemfile bundle install &&
BUNDLE_GEMFILE=$gemfile bundle exec rake)
then
exit 1
fi
done
3 changes: 2 additions & 1 deletion spec/integration/integration_helper.rb
Expand Up @@ -53,6 +53,7 @@ def execute(*args)
connection.execute(*args)
rescue ActiveRecord::StatementInvalid => e
if (retries -= 1) > 0 && e.message =~ /Table '.*?' doesn't exist/
sleep 0.1
retry
else
raise
Expand Down Expand Up @@ -122,7 +123,7 @@ def index_on_columns?(table_name, cols, type = :non_unique)
def index?(table_name, key_name, type = :non_unique)
non_unique = type == :non_unique ? 1 : 0

!!select_value(%Q<
!!select_one(%Q<
show indexes in #{ table_name }
where key_name = '#{ key_name }'
and non_unique = #{ non_unique }
Expand Down

0 comments on commit 64d27ad

Please sign in to comment.