From b125036f79b5c12ffd85146cceeed8e99c14eeb3 Mon Sep 17 00:00:00 2001 From: Robert Newson Date: Thu, 18 Mar 2021 15:44:52 +0000 Subject: Add Secondary data tests with updates test --- test/elixir/test/concurrent_writes_test.exs | 24 ++++++++++++++++++++++++ test/elixir/test/config/suite.elixir | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/test/elixir/test/concurrent_writes_test.exs b/test/elixir/test/concurrent_writes_test.exs index bf3c0a652..397c5e880 100644 --- a/test/elixir/test/concurrent_writes_test.exs +++ b/test/elixir/test/concurrent_writes_test.exs @@ -48,4 +48,28 @@ defmodule ConcurrentWritesTest do assert result == Enum.sum(1..n) end + @tag :with_db + test "Secondary data tests with updates", context do + n = 120 + db_name = context[:db_name] + map_fun = "function(doc) { emit(null, doc.a); }" + red_fun = "_sum" + ddoc_id = "_design/foo" + ddoc = %{:views => %{:foo => %{:map => map_fun, :reduce => red_fun}}} + Couch.put("/#{db_name}/#{ddoc_id}", body: ddoc) + parent = self() + Enum.each(1..n, + fn x -> spawn fn -> + r = Couch.put("/#{db_name}/doc#{x}", body: %{:a => x}) + assert r.status_code == 201 + rev = r.body["rev"] + Couch.put("/#{db_name}/doc#{x}", body: %{:_rev => rev, :a => x + 1}) + send parent, :done + end end) + Enum.each(1..n, fn _x -> receive do :done -> :done end end) + rows = Couch.get("/#{db_name}/#{ddoc_id}/_view/foo").body["rows"] + result = hd(rows)["value"] + assert result == Enum.sum(2..n + 1) + end + end diff --git a/test/elixir/test/config/suite.elixir b/test/elixir/test/config/suite.elixir index 65f972c2f..c508b4449 100644 --- a/test/elixir/test/config/suite.elixir +++ b/test/elixir/test/config/suite.elixir @@ -133,7 +133,8 @@ ], "ConcurrentWritesTest": [ "Primary data tests", - "Secondary data tests" + "Secondary data tests", + "Secondary data tests with updates" ], "ConfigTest": [ "Atoms, binaries, and strings suffice as whitelist sections and keys.", -- cgit v1.2.1