Commit 2bd88b0f2aa317343204964471c3a05a1b629c70

Authored by Luke Baker
1 parent 181859c6

add descriptive errors

Showing 1 changed file with 5 additions and 5 deletions   Show diff stats
lib/tasks/test_api.rake
@@ -196,7 +196,7 @@ namespace :test_api do @@ -196,7 +196,7 @@ namespace :test_api do
196 SELECT COUNT(*) AS total FROM prompts 196 SELECT COUNT(*) AS total FROM prompts
197 WHERE question_id = #{question.id} AND right_choice_id IN (SELECT id from choices where question_id = #{question.id})") 197 WHERE question_id = #{question.id} AND right_choice_id IN (SELECT id from choices where question_id = #{question.id})")
198 if (generated_on_left["total"] != generated_on_right["total"]) 198 if (generated_on_left["total"] != generated_on_right["total"])
199 - error_message = "Error 4: Total generated prompts on left != Total generated prompts on right" 199 + error_message = "Question #{question.id}: Total generated prompts on left (#{generated_on_left["total"]}) != Total generated prompts on right (#{generated_on_right["total"]})"
200 end 200 end
201 return error_message.blank? ? [success_message, false] : [error_message, true] 201 return error_message.blank? ? [success_message, false] : [error_message, true]
202 end 202 end
@@ -215,7 +215,7 @@ namespace :test_api do @@ -215,7 +215,7 @@ namespace :test_api do
215 total_scores_gte_fifty = totals_gte_fifty["total"] 215 total_scores_gte_fifty = totals_gte_fifty["total"]
216 question_choices_count = question.choices.count 216 question_choices_count = question.choices.count
217 if (total_scores_lte_fifty == question_choices_count || total_scores_gte_fifty == question_choices_count) && (total_scores_lte_fifty != total_scores_gte_fifty) 217 if (total_scores_lte_fifty == question_choices_count || total_scores_gte_fifty == question_choices_count) && (total_scores_lte_fifty != total_scores_gte_fifty)
218 - error_message = "Error! Question #{question.id}: The scores of all choices are either all above 50, or all below 50. This is probably wrong" 218 + error_message = "Question #{question.id}: The scores of all choices are either all above 50, or all below 50. This is probably wrong"
219 end 219 end
220 return error_message.blank? ? [success_message, false] : [error_message, true] 220 return error_message.blank? ? [success_message, false] : [error_message, true]
221 end 221 end
@@ -230,7 +230,7 @@ namespace :test_api do @@ -230,7 +230,7 @@ namespace :test_api do
230 SUM(losses) AS total_losses FROM choices 230 SUM(losses) AS total_losses FROM choices
231 WHERE question_id = #{question.id}") 231 WHERE question_id = #{question.id}")
232 if(totals["total"] != 2* question.votes_count) 232 if(totals["total"] != 2* question.votes_count)
233 - error_message = "Error: Total votes != 2 x # vote objects" 233 + error_message = "Question #{question.id}: Total votes != 2 x # vote objects, total: #{totals["total"]}, vote_count: #{question.votes_count}"
234 end 234 end
235 return error_message.blank? ? [success_message, false] : [error_message, true] 235 return error_message.blank? ? [success_message, false] : [error_message, true]
236 end 236 end
@@ -245,7 +245,7 @@ namespace :test_api do @@ -245,7 +245,7 @@ namespace :test_api do
245 SUM(losses) AS total_losses FROM choices 245 SUM(losses) AS total_losses FROM choices
246 WHERE question_id = #{question.id}") 246 WHERE question_id = #{question.id}")
247 if (!totals["total"].blank? && totals["total"] % 2 != 0) 247 if (!totals["total"].blank? && totals["total"] % 2 != 0)
248 - error_message = "Error: Total votes is not Even!" 248 + error_message = "Question #{question.id}: Total votes is not even: #{totals["total"]}"
249 end 249 end
250 return error_message.blank? ? [success_message, false] : [error_message, true] 250 return error_message.blank? ? [success_message, false] : [error_message, true]
251 end 251 end
@@ -260,7 +260,7 @@ namespace :test_api do @@ -260,7 +260,7 @@ namespace :test_api do
260 SUM(losses) AS total_losses FROM choices 260 SUM(losses) AS total_losses FROM choices
261 WHERE question_id = #{question.id}") 261 WHERE question_id = #{question.id}")
262 if (2*totals["total_wins"].to_i != totals["total"].to_i) 262 if (2*totals["total_wins"].to_i != totals["total"].to_i)
263 - error_message = "Error: 2 x Total Wins != Total votes" 263 + error_message = "Question #{question.id}: 2 x Total Wins != Total votes. wins: #{2*totals["total_wins"].to_i}, total: #{totals["total"].to_i}"
264 end 264 end
265 return error_message.blank? ? [success_message, false] : [error_message, true] 265 return error_message.blank? ? [success_message, false] : [error_message, true]
266 end 266 end