Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
.vscode
.rebar/
.eunit/
.hypothesis/
cover/
/core
debian/
Expand Down Expand Up @@ -64,12 +63,14 @@ src/hqueue/
src/ibrowse/
src/idna/
src/jiffy/
src/libgraph/
src/meck/
src/metrics/
src/mimerl/
src/mochiweb/
src/oauth/
src/parse_trans/
src/propcheck/
src/proper/
src/rebar/
src/recon/
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,12 @@ elixir-cluster-with-quorum: elixir-init devclean

.PHONY: elixir
# target: elixir - Run Elixir-based integration tests
elixir: export MIX_ENV=integration
elixir: elixir-init devclean
@$(MAKE) elixir-test

.PHONY: elixir-test
elixir-test: export MIX_ENV=integration
elixir-test:
@dev/run "$(TEST_OPTS)" -n 1 -q -a adm:pass \
--enable-erlang-views \
--no-join \
Expand Down
8 changes: 6 additions & 2 deletions Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,13 @@ elixir-cluster-with-quorum: elixir-init devclean

.PHONY: elixir
# target: elixir - Run Elixir-based integration tests
elixir: export MIX_ENV=integration
elixir: export COUCHDB_TEST_ADMIN_PARTY_OVERRIDE=1
elixir: elixir-init devclean
@$(MAKE) elixir-test

.PHONY: elixir-test
elixir-test: export MIX_ENV=integration
elixir-test: export COUCHDB_TEST_ADMIN_PARTY_OVERRIDE=1
elixir-test: elixir-init devclean
@dev\run "$(TEST_OPTS)" -n 1 -q -a adm:pass \
--enable-erlang-views \
--no-join \
Expand Down
4 changes: 2 additions & 2 deletions README-DEV.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Gentoo-based Systems
::

sudo emerge gnupg coreutils pkgconfig help2man sphinx python
sudo pip install hypothesis requests nose
sudo pip install requests nose

Centos 7 and RHEL 7
~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -136,7 +136,7 @@ FreeBSD
::

pkg install help2man gnupg py27-sphinx node
pip install nose requests hypothesis
pip install nose requests

Windows
~~~~~~~
Expand Down
5 changes: 5 additions & 0 deletions erlang_ls.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ apps_dirs:
include_dirs:
- "src"
- "src/*/include"
macros:
- name: WITH_PROPER
value: true
- name: TEST
value: true
8 changes: 5 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ defmodule CouchDBTest.Mixfile do
tool: CoverTool,
dirs: get_coverage_paths(),
type: "html"
]
],
propcheck: []
]
end

# Run "mix help compile.app" to learn about applications.
def application, do: [applications: [:logger, :httpotion]]
def application, do: [applications: [:logger, :httpotion, :propcheck]]

# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["test/elixir/lib", "test/elixir/test/support"]
Expand All @@ -85,7 +86,8 @@ defmodule CouchDBTest.Mixfile do
{:httpotion, ">= 3.2.0", only: [:dev, :test, :integration], runtime: false},
{:excoveralls, "~> 0.18.3", only: :test},
{:ibrowse, path: path("ibrowse"), override: true},
{:credo, "~> 1.7.11", only: [:dev, :test, :integration], runtime: false}
{:credo, "~> 1.7.11", only: [:dev, :test, :integration], runtime: false},
{:propcheck, "~> 1.5", only: [:dev, :test, :integration]}
]

extra_deps = [:b64url, :jiffy, :jwtf, :meck, :mochiweb]
Expand Down
3 changes: 1 addition & 2 deletions src/mango/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# nose2 0.13.0, requests, hypothesis version are driven
# nose2 0.13.0, requests version are driven
# by the minimum version for python on centos 8 currently
nose2==0.13.0
requests==2.32.4
hypothesis==6.31.6
39 changes: 0 additions & 39 deletions src/mango/test/06-basic-text-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
import unittest
import user_docs
import math
from hypothesis import given, assume, example, settings
import hypothesis.strategies as st


@unittest.skipIf(mango.has_text_service(), "text service exists")
class TextIndexCheckTests(mango.DbPerClass):
Expand Down Expand Up @@ -564,39 +561,3 @@ def test_all_match(self):
docs = self.db.find(q)
assert len(docs) == 1
assert docs[0]["user_id"] == 15


# Test numeric strings for $text
@unittest.skipUnless(mango.has_text_service(), "requires text service")
class NumStringTests(mango.DbPerClass):
@classmethod
def setUpClass(klass):
super(NumStringTests, klass).setUpClass()
klass.db.recreate()
klass.db.create_text_index()

# not available for python 2.7.x
def isFinite(num):
not (math.isinf(num) or math.isnan(num))

@given(f=st.floats().filter(isFinite).map(str) | st.floats().map(lambda f: f.hex()))
@settings(deadline=1000)
@example("NaN")
@example("Infinity")
def test_floating_point_val(self, f):
doc = {"number_string": f}
self.db.save_doc(doc)
q = {"$text": f}
docs = self.db.find(q)
if len(docs) == 1:
assert docs[0]["number_string"] == f
if len(docs) == 2:
if docs[0]["number_string"] != f:
assert docs[1]["number_string"] == f
q = {"number_string": f}
docs = self.db.find(q)
if len(docs) == 1:
assert docs[0]["number_string"] == f
if len(docs) == 2:
if docs[0]["number_string"] != f:
assert docs[1]["number_string"] == f
3 changes: 3 additions & 0 deletions test/elixir/test/config/search.elixir
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,8 @@
],
"RegexVsTextIndexTest": [
"regex works with text index"
],
"NumStringTests": [
"single floating point test"
]
}
2 changes: 1 addition & 1 deletion test/elixir/test/config/test-config.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[log]
level = warn
level = notice

[chttpd]
authentication_handlers = {chttpd_auth, jwt_authentication_handler}, {chttpd_auth, proxy_authentication_handler}, {chttpd_auth, cookie_authentication_handler}, {chttpd_auth, default_authentication_handler}
Expand Down
50 changes: 50 additions & 0 deletions test/elixir/test/mango/06_basic_text_prop_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
defmodule NumStringTests do
use PropCheck
use CouchTestCase

@moduletag :search_props
@db_name "changeme-proptest-db"

property "test floating point value",
numtests: 1_000 do # takes about 10 seconds
MangoDatabase.recreate("/#{@db_name}")
forall f <- weighted_union([{100, float()}, {1, "NaN"}, {1, "Infinity"}]) do
# create doc with float
:ok == test_float(f)
end
end

# this is used to test the inner logic, as that
# is a bit tricky from inside the property
test "single floating point test" do
MangoDatabase.recreate("/#{@db_name}")
test_float(3.14)
end

def test_float(f) do
doc = %{"number_string" => f}
# save doc
Couch.post("/#{@db_name}", body: doc)
# run find with same float as $text
{:ok, docs} = MangoDatabase.find(@db_name, %{"$text" => f})
# if result length = 1, assert docs[0] == f
assert_result(docs, f)
# run find again with same float as field name match
{:ok, docs} = MangoDatabase.find(@db_name, %{"number_text" => f})
# repeat same tests
assert_result(docs, f)
:ok
end

def assert_result(docs, f) do
cond do
Enum.count(docs) == 1 ->
assert Enum.at(docs, 0)["number_string"] == f
Enum.count(docs) == 2 ->
if Enum.at(docs, 0)["number_string"] != f do
assert Enum.at(docs, 1)["number_string"] == f
end
true -> true
end
end
end