jaydoane commented on code in PR #5692:
URL: https://github.com/apache/couchdb/pull/5692#discussion_r2414589599


##########
test/elixir/test/partition_search_test.exs:
##########
@@ -22,7 +22,9 @@ defmodule PartitionSearchTest do
     end
 
     resp = Couch.post("/#{db_name}/_bulk_docs", headers: ["Content-Type": 
"application/json"], body: %{:docs => docs}, query: %{w: 3})
-    assert resp.status_code in [201, 202]
+    assert resp.status_code in [201, 202],
+      "Cannot create search docs. " <>
+      "Expected one of [201, 202], got: #{resp.status_code}, body: #{inspect 
resp.body}"

Review Comment:
   This is a great idea, and I wonder if we could create a function to DRY it 
out a little?
   ```elixir
   def expect_status(resp, expected, failure_description) do
     expected_list = List.wrap(expected)
   
     expected_msg = case expected_list do
       [single] -> "Expected #{single}"
       multiple -> "Expected one of #{inspect(multiple)}"
     end
   
     assert resp.status_code in expected_list,
       "#{failure_description} #{expected_msg}, got: #{resp.status_code}, body: 
#{inspect(resp.body)}"
   end
   ```
   then we could just do
   ```elixir
   expect_status(resp, [201, 202], "Cannot create search docs. ")
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to