Commit 2bd88b0f2aa317343204964471c3a05a1b629c70
1 parent
181859c6
Exists in
master
and in
1 other branch
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 | 196 | SELECT COUNT(*) AS total FROM prompts |
197 | 197 | WHERE question_id = #{question.id} AND right_choice_id IN (SELECT id from choices where question_id = #{question.id})") |
198 | 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 | 200 | end |
201 | 201 | return error_message.blank? ? [success_message, false] : [error_message, true] |
202 | 202 | end |
... | ... | @@ -215,7 +215,7 @@ namespace :test_api do |
215 | 215 | total_scores_gte_fifty = totals_gte_fifty["total"] |
216 | 216 | question_choices_count = question.choices.count |
217 | 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 | 219 | end |
220 | 220 | return error_message.blank? ? [success_message, false] : [error_message, true] |
221 | 221 | end |
... | ... | @@ -230,7 +230,7 @@ namespace :test_api do |
230 | 230 | SUM(losses) AS total_losses FROM choices |
231 | 231 | WHERE question_id = #{question.id}") |
232 | 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 | 234 | end |
235 | 235 | return error_message.blank? ? [success_message, false] : [error_message, true] |
236 | 236 | end |
... | ... | @@ -245,7 +245,7 @@ namespace :test_api do |
245 | 245 | SUM(losses) AS total_losses FROM choices |
246 | 246 | WHERE question_id = #{question.id}") |
247 | 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 | 249 | end |
250 | 250 | return error_message.blank? ? [success_message, false] : [error_message, true] |
251 | 251 | end |
... | ... | @@ -260,7 +260,7 @@ namespace :test_api do |
260 | 260 | SUM(losses) AS total_losses FROM choices |
261 | 261 | WHERE question_id = #{question.id}") |
262 | 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 | 264 | end |
265 | 265 | return error_message.blank? ? [success_message, false] : [error_message, true] |
266 | 266 | end | ... | ... |