summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2023-04-26 15:03:22 +0100
committerRobert Newson <rnewson@apache.org>2023-04-27 10:32:15 +0100
commit6f39ae7349f24e0fe89511600368b3e1dfe8953f (patch)
tree7c5bb0600fa9b6a3348a0bd8d76b75c44bef404b
parentf4f04e0929d07b37b61508e00e507cf42978d8ef (diff)
downloadcouchdb-6f39ae7349f24e0fe89511600368b3e1dfe8953f.tar.gz
mango end-to-end tests for nouveau
-rw-r--r--test/elixir/test/config/nouveau.elixir4
-rw-r--r--test/elixir/test/nouveau_test.exs46
2 files changed, 49 insertions, 1 deletions
diff --git a/test/elixir/test/config/nouveau.elixir b/test/elixir/test/config/nouveau.elixir
index 90390a9d6..fdcc66de2 100644
--- a/test/elixir/test/config/nouveau.elixir
+++ b/test/elixir/test/config/nouveau.elixir
@@ -12,6 +12,8 @@
"sort by numeric field (desc)",
"counts",
"ranges",
- "ranges (open)"
+ "ranges (open)",
+ "mango search by number",
+ "mango search by string"
]
}
diff --git a/test/elixir/test/nouveau_test.exs b/test/elixir/test/nouveau_test.exs
index ee5d20542..357dcbba7 100644
--- a/test/elixir/test/nouveau_test.exs
+++ b/test/elixir/test/nouveau_test.exs
@@ -42,11 +42,31 @@ defmodule NouveauTest do
assert Map.has_key?(resp.body, "ok") == true
end
+ def create_mango_index(db_name) do
+ body = %{
+ type: "nouveau",
+ index: %{
+ fields: [
+ %{name: "foo", type: "string"},
+ %{name: "bar", type: "number"}
+ ]
+ }
+ }
+
+ resp = Couch.post("/#{db_name}/_index", body: body)
+ assert resp.status_code in [200]
+ end
+
def get_ids(resp) do
%{:body => %{"hits" => hits}} = resp
Enum.map(hits, fn hit -> hit["doc"]["_id"] end)
end
+ def get_mango_ids(resp) do
+ %{:body => %{"docs" => docs}} = resp
+ Enum.map(docs, fn doc -> doc["_id"] end)
+ end
+
def get_bookmark(resp) do
%{:body => %{"bookmark" => bookmark}} = resp
bookmark
@@ -239,4 +259,30 @@ defmodule NouveauTest do
assert ranges == %{"bar" => %{"cheap" => 3, "expensive" => 1}}
end
+ @tag :with_db
+ test "mango search by number", context do
+ db_name = context[:db_name]
+ create_search_docs(db_name)
+ create_mango_index(db_name)
+
+ url = "/#{db_name}/_find"
+ resp = Couch.post(url, body: %{selector: %{bar: %{"$gt": 5}}})
+ assert resp.status_code == 200, "error #{resp.status_code} #{:jiffy.encode(resp.body)}"
+ ids = get_mango_ids(resp)
+ assert ids == ["doc2", "doc3", "doc4"]
+ end
+
+ @tag :with_db
+ test "mango search by string", context do
+ db_name = context[:db_name]
+ create_search_docs(db_name)
+ create_mango_index(db_name)
+
+ url = "/#{db_name}/_find"
+ resp = Couch.post(url, body: %{selector: %{foo: %{"$eq": "foo"}}})
+ assert resp.status_code == 200, "error #{db_name} #{resp.status_code} #{:jiffy.encode(resp.body)}"
+ ids = get_mango_ids(resp)
+ assert ids == ["doc4"]
+ end
+
end