You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/07/25 17:44:24 UTC

[GitHub] garrensmith closed pull request #1467: Port batch_save.js

garrensmith closed pull request #1467: Port batch_save.js
URL: https://github.com/apache/couchdb/pull/1467
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/test/elixir/test/batch_save_test.exs b/test/elixir/test/batch_save_test.exs
new file mode 100644
index 0000000000..4863a8d030
--- /dev/null
+++ b/test/elixir/test/batch_save_test.exs
@@ -0,0 +1,42 @@
+defmodule BatchSaveTest do
+  use CouchTestCase
+
+  @moduletag :batch_save
+
+  @moduledoc """
+  Test CouchDB batch save
+  This is a port of batch_save.js
+  """
+
+  @doc_count 100
+
+  @tag :with_db
+  test "batch put", context do
+    path_fun = &("/#{&1}/#{&2}")
+    run(&Couch.put/2, path_fun, context[:db_name], @doc_count)
+  end
+
+  @tag :with_db
+  test "batch post", context do
+    path_fun = fn(db_name, _) -> "/#{db_name}" end
+    run(&Couch.post/2, path_fun, context[:db_name], @doc_count)
+  end
+
+  @tag :with_db
+  test "batch put with identical doc ids", context do
+    path_fun = fn(db_name, _) -> "/#{db_name}/foo" end
+    run(&Couch.put/2, path_fun, context[:db_name], 1)
+  end
+
+  defp run(req_fun, path_fun, db_name, expected_doc_count) do
+    for i <- 1..@doc_count do
+      opts = [body: %{a: i, b: i}, query: %{batch: "ok"}]
+      resp = req_fun.(path_fun.(db_name, i), opts)
+      assert resp.body["ok"] and resp.status_code == 202
+    end
+    retry_until(fn ->
+      Couch.get("/#{db_name}").body["doc_count"] == expected_doc_count
+    end)
+  end
+
+end


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services