jaydoane commented on a change in pull request #2101: Refactor 
fabric:cleanup_index_files
URL: https://github.com/apache/couchdb/pull/2101#discussion_r314396229
 
 

 ##########
 File path: src/couch/test/exunit/fabric_test.exs
 ##########
 @@ -0,0 +1,101 @@
+defmodule Couch.Test.Fabric do
+  use Couch.Test.ExUnit.Case
+  alias Couch.Test.Utils
+
+  alias Couch.Test.Setup
+
+  alias Couch.Test.Setup.Step
+
+  import Couch.DBTest
+
+  import Utils
+
+  @admin {:user_ctx, user_ctx(roles: ["_admin"])}
+
+  def with_db(context, setup) do
+    setup =
+      setup
+      |> Setup.Common.with_db()
+      |> Setup.run()
+
+    context =
+      Map.merge(context, %{
+        db_name: setup |> Setup.get(:db) |> Step.Create.DB.name()
+      })
+
+    {context, setup}
+  end
+
+  describe "Fabric miscellaneous API" do
+    @describetag setup: &__MODULE__.with_db/2
+    test "Get non_active_index_files", ctx do
+      {:ok, _rev} = update_doc(ctx.db_name, %{"_id" => "doc1"})
+
+      design_doc = %{
+        "_id" => "_design/test",
+        "language" => "javascript",
+        "views" => %{
+          "view" => %{
+            "map" => "function(doc){emit(doc._id, doc._rev)}"
+          }
+        }
+      }
+
+      {:ok, rev1} = update_doc(ctx.db_name, design_doc)
+      wait_sig_update(ctx.db_name, "test", "")
+      prev_active = get_active_sig(ctx.db_name, "test")
+
+      updated_design_doc =
+        put_in(design_doc, ["views", "view", "map"], 
"function(doc){emit(doc._id, null)}")
+
+      {:ok, rev2} =
+        update_doc(
+          ctx.db_name,
+          Map.put(updated_design_doc, "_rev", rev1)
+        )
+
+      assert rev1 != rev2
+      wait_sig_update(ctx.db_name, "test", prev_active)
+
+      {:ok, info} = :fabric.get_view_group_info(ctx.db_name, "_design/test")
+      active = info[:signature]
+
+      files = Enum.map(:fabric.non_active_index_files(ctx.db_name), 
&List.to_string/1)
+
+      assert [] != files, "We should have some non active"
 
 Review comment:
   Please change this to "We should have some inactive index files" or 
something like that

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to