Skip to content

Commit d9c059e

Browse files
authored
Update Elixir tests and config files (#5822)
* Update Elixir tests - Elixir unit tests need to end with `_test.exs` to run. - large_docs_test.exs - reshard_changes_feed_test.exs - disk_monitor_test.exs - 04_key_test.exs - 25_beginswith_test.exs - The `Enum.each()` method cannot run tests because it iterates through the data at runtime, while the test macro is defined at compile time. Therefore, replace it with a for loop. - rewrite_js_test.exs - rewrite_test.exs - Update outdated tests. - cluster_with_quorum_test.exs - cluster_without_quorum_test.exs - cookie_auth_test.exs * Fix Elixir test compile-time warnings - warning: variable "db" is unused (if the variable is not meant to be used, prefix it with an underscore). - friend_docs.ex - limit_docs.ex - warning: using single-quoted strings to represent charlists is deprecated. - user_docs.ex - warning: trailing commas are not allowed inside function/macro call arguments. - 02_basic_find_test.exs * Update Elixir test config files - config/search.elixir - config/skip.elixir - config/suite.elixir
1 parent 565074d commit d9c059e

17 files changed

Lines changed: 725 additions & 771 deletions

test/elixir/test/cluster_with_quorum_test.exs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ defmodule WithQuorumTest do
77
Test CouchDB API in a cluster without quorum.
88
"""
99
@tag :with_db_name
10-
test "Creating/Deleting DB should return 201-Created/202-Acepted", context do
10+
test "Creating/Deleting DB should return 201-Created/200-OK", context do
1111
db_name = context[:db_name]
1212
resp = Couch.put("/#{db_name}")
1313
msg = "Should return 201-Created"
1414
assert resp.status_code in [201, 202], msg
1515
resp = Couch.delete("/#{db_name}")
16-
msg = "Should return 202-Acepted"
17-
assert resp.status_code == 202, msg
16+
msg = "Should return 200-OK"
17+
assert resp.status_code == 200, msg
1818
end
1919

2020
@tag :with_db_name
@@ -45,7 +45,7 @@ defmodule WithQuorumTest do
4545
end
4646

4747
@tag :with_db_name
48-
test "Creating-Updating/Deleting doc with overriden quorum should return 202-Acepted/200-OK",
48+
test "Creating-Updating/Deleting doc with overridden quorum should return 202-Accepted/200-OK",
4949
context do
5050
db_name = context[:db_name]
5151
Couch.put("/#{db_name}")
@@ -57,7 +57,7 @@ defmodule WithQuorumTest do
5757
body: %{:_id => "0", :a => 1}
5858
)
5959

60-
msg = "Should return 202-Acepted"
60+
msg = "Should return 202-Accepted"
6161
assert resp.status_code == 202, msg
6262

6363
resp = Couch.get("/#{context[:db_name]}/0")
@@ -70,7 +70,7 @@ defmodule WithQuorumTest do
7070
body: %{:_id => "0", :_rev => rev, :a => 2}
7171
)
7272

73-
msg = "Should return 202-Acepted"
73+
msg = "Should return 202-Accepted"
7474
assert resp.status_code == 202, msg
7575

7676
resp = Couch.get("/#{context[:db_name]}/0")
@@ -114,12 +114,12 @@ defmodule WithQuorumTest do
114114
end
115115

116116
@tag :with_db_name
117-
test "Bulk docs overriden quorum should return 202-Acepted", context do
117+
test "Bulk docs overridden quorum should return 202-Accepted", context do
118118
db_name = context[:db_name]
119119
Couch.put("/#{db_name}")
120120
docs = create_docs(@doc_range)
121121
resp = Couch.post("/#{db_name}/_bulk_docs", query: %{:w => 3}, body: %{docs: docs})
122-
msg = "Should return 202-Acepted"
122+
msg = "Should return 202-Accepted"
123123
assert resp.status_code == 202, msg
124124

125125
Couch.delete("/#{db_name}")
@@ -152,7 +152,7 @@ defmodule WithQuorumTest do
152152
end
153153

154154
@tag :with_db_name
155-
test "Attachments overriden quorum should return 202-Acepted", context do
155+
test "Attachments overridden quorum should return 202-Accepted", context do
156156
db_name = context[:db_name]
157157
Couch.put("/#{db_name}")
158158
resp = Couch.post("/#{context[:db_name]}", body: %{:_id => "0"})
@@ -166,7 +166,7 @@ defmodule WithQuorumTest do
166166
headers: ["Content-Type": "text/plain;charset=utf-8"]
167167
)
168168

169-
msg = "Should return 202-Acepted"
169+
msg = "Should return 202-Accepted"
170170
assert resp.status_code == 202, msg
171171

172172
rev = resp.body["rev"]

test/elixir/test/cluster_without_quorum_test.exs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,45 @@ defmodule WithoutQuorumTest do
77
Test CouchDB API in a cluster without quorum.
88
"""
99
@tag :with_db_name
10-
test "Creating/Deleting DB should return 202-Acepted", context do
10+
test "Creating/Deleting DB should return 201-Created/200-OK", context do
1111
db_name = context[:db_name]
1212
resp = Couch.put("/#{db_name}")
13-
msg = "Should return 202-Acepted"
14-
assert resp.status_code == 202, msg
13+
msg = "Should return 201-Created"
14+
assert resp.status_code == 201, msg
1515
resp = Couch.delete("/#{db_name}")
16-
assert resp.status_code == 202, msg
16+
msg = "Should return 200-OK"
17+
assert resp.status_code == 200, msg
1718
end
1819

1920
@tag :with_db_name
20-
test "Creating/Updating/Deleting doc should return 202-Acepted", context do
21+
test "Creating/Updating/Deleting doc should return 201-Created/200-OK", context do
2122
db_name = context[:db_name]
2223
Couch.put("/#{db_name}")
2324

2425
resp = Couch.post("/#{context[:db_name]}", body: %{:_id => "0", :a => 1})
25-
msg = "Should return 202-Acepted"
26-
assert resp.status_code == 202, msg
26+
msg = "Should return 201-Created"
27+
assert resp.status_code == 201, msg
2728

2829
resp = Couch.get("/#{context[:db_name]}/0")
2930
rev = resp.body["_rev"]
3031

3132
resp =
3233
Couch.put("/#{context[:db_name]}/0", body: %{:_id => "0", :_rev => rev, :a => 2})
3334

34-
msg = "Should return 202-Acepted"
35-
assert resp.status_code == 202, msg
35+
msg = "Should return 201-Created"
36+
assert resp.status_code == 201, msg
3637

3738
resp = Couch.get("/#{context[:db_name]}/0")
3839
rev = resp.body["_rev"]
3940
resp = Couch.delete("/#{context[:db_name]}/0", query: %{:rev => rev})
40-
msg = "Should return 202-Acepted"
41-
assert resp.status_code == 202, msg
41+
msg = "Should return 200-OK"
42+
assert resp.status_code == 200, msg
4243

4344
Couch.delete("/#{db_name}")
4445
end
4546

4647
@tag :with_db_name
47-
test "Creating-Updating/Deleting doc with overriden quorum should return 201-Created/200-OK",
48+
test "Creating-Updating/Deleting doc with overridden quorum should return 201-Created/200-OK",
4849
context do
4950
db_name = context[:db_name]
5051
Couch.put("/#{db_name}")
@@ -82,7 +83,7 @@ defmodule WithoutQuorumTest do
8283
end
8384

8485
@tag :with_db_name
85-
test "Copy doc should return 202-Acepted", context do
86+
test "Copy doc should return 201-Created", context do
8687
db_name = context[:db_name]
8788
Couch.put("/#{db_name}")
8889

@@ -93,27 +94,27 @@ defmodule WithoutQuorumTest do
9394

9495
headers = [Destination: "1"]
9596
resp = Couch.request(:copy, "/#{context[:db_name]}/0", headers: headers)
96-
msg = "Should return 202-Acepted"
97-
assert resp.status_code == 202, msg
97+
msg = "Should return 201-Created"
98+
assert resp.status_code == 201, msg
9899
Couch.delete("/#{db_name}")
99100
end
100101

101102
@doc_range 1..5
102103

103104
@tag :with_db_name
104-
test "Bulk docs should return 202-Acepted", context do
105+
test "Bulk docs should return 201-Created", context do
105106
db_name = context[:db_name]
106107
Couch.put("/#{db_name}")
107108
docs = create_docs(@doc_range)
108109
resp = Couch.post("/#{db_name}/_bulk_docs", body: %{docs: docs})
109-
msg = "Should return 202-Acepted"
110-
assert resp.status_code == 202, msg
110+
msg = "Should return 201-Created"
111+
assert resp.status_code == 201, msg
111112

112113
Couch.delete("/#{db_name}")
113114
end
114115

115116
@tag :with_db_name
116-
test "Bulk docs overriden quorum should return 201-Created", context do
117+
test "Bulk docs overridden quorum should return 201-Created", context do
117118
db_name = context[:db_name]
118119
Couch.put("/#{db_name}")
119120
docs = create_docs(@doc_range)
@@ -125,7 +126,7 @@ defmodule WithoutQuorumTest do
125126
end
126127

127128
@tag :with_db_name
128-
test "Attachments should return 202-Acepted", context do
129+
test "Attachments should return 201-Created", context do
129130
db_name = context[:db_name]
130131
Couch.put("/#{db_name}")
131132
resp = Couch.post("/#{context[:db_name]}", body: %{:_id => "0"})
@@ -139,8 +140,8 @@ defmodule WithoutQuorumTest do
139140
headers: ["Content-Type": "text/plain;charset=utf-8"]
140141
)
141142

142-
msg = "Should return 202-Acepted"
143-
assert resp.status_code == 202, msg
143+
msg = "Should return 201-Created"
144+
assert resp.status_code == 201, msg
144145

145146
rev = resp.body["rev"]
146147
resp = Couch.delete("/#{context[:db_name]}/0/foo.txt", query: %{:rev => rev})
@@ -151,7 +152,7 @@ defmodule WithoutQuorumTest do
151152
end
152153

153154
@tag :with_db_name
154-
test "Attachments overriden quorum should return 201-Created", context do
155+
test "Attachments overridden quorum should return 201-Created", context do
155156
db_name = context[:db_name]
156157
Couch.put("/#{db_name}")
157158
resp = Couch.post("/#{context[:db_name]}", body: %{:_id => "0"})

test/elixir/test/config/search.elixir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"facet counts, non-empty",
3232
"facet counts, empty",
3333
"facet ranges, empty",
34-
"facet ranges, non-empty"
34+
"facet ranges, non-empty",
35+
"timeouts do not expose internal state"
3536
],
3637
"ElemMatchTests": [
3738
"elem match non object"
Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
11
%{
2-
"CookieAuthTest": [
3-
"cookie auth"
4-
],
5-
"ReaderACLTest": [
6-
"unrestricted db can be read"
7-
],
82
"ReplicationTest": [
9-
"non-admin user on target - remote-to-remote",
103
"non-admin or reader user on source - remote-to-remote",
4+
"non-admin user on target - remote-to-remote",
115
"unauthorized replication cancellation"
12-
],
13-
"SecurityValidationTest": [
14-
"Author presence and user security when replicated"
15-
],
16-
"WithQuorumTest": [
17-
"Creating/Deleting DB should return 201-Created/202-Acepted"
18-
],
19-
"WithoutQuorumTest": [
20-
"Attachments should return 202-Acepted",
21-
"Bulk docs should return 202-Acepted",
22-
"Copy doc should return 202-Acepted",
23-
"Creating/Deleting DB should return 202-Acepted",
24-
"Creating/Updating/Deleting doc should return 202-Acepted"
256
]
267
}

test/elixir/test/config/suite.elixir

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"etags for attachments",
3737
"implicit doc creation allows creating docs with a reserved id. COUCHDB-565",
3838
"large attachments COUCHDB-366",
39-
"md5 header for attachments",
4039
"reads attachment successfully",
4140
"saves attachment successfully",
4241
"saves binary",
@@ -48,7 +47,7 @@
4847
],
4948
"AuthLockoutTest": [
5049
"lockout after multiple failed authentications",
51-
"lockout warning after multiple failed authentications"
50+
"do not lockout after multiple failed authentications"
5251
],
5352
"BasicsTest": [
5453
"'+' in document name should encode to '+'",
@@ -156,7 +155,8 @@
156155
"Only JSON strings are accepted"
157156
],
158157
"CookieAuthTest": [
159-
"cookie auth"
158+
"cookie auth",
159+
"header doesn't contain set-cookie"
160160
],
161161
"CopyDocTest": [
162162
"Copy doc tests"
@@ -257,6 +257,9 @@
257257
"jwt auth with required iss claim",
258258
"jwt auth without secret"
259259
],
260+
"LargeDocsTest": [
261+
"Large docs"
262+
],
260263
"ListViewsTest": [
261264
"COUCHDB-1113",
262265
"HTTP header response set after getRow() called in _list function",
@@ -413,7 +416,7 @@
413416
"view updates properly remove old keys"
414417
],
415418
"PasswordCacheTest": [
416-
"password cache"
419+
"password hash cache"
417420
],
418421
"ProxyAuthTest": [
419422
"proxy auth with secret",
@@ -458,16 +461,13 @@
458461
"default headers returned for _scheduler/docs ",
459462
"default headers returned for _scheduler/jobs",
460463
"filtered replications - remote-to-remote",
461-
"non-admin or reader user on source - remote-to-remote",
462-
"non-admin user on target - remote-to-remote",
463464
"replicate with since_seq - remote-to-remote",
464465
"replicating attachment without conflict - COUCHDB-885",
465466
"replication by doc ids - remote-to-remote",
466467
"replication cancellation",
467468
"replication restarts after filter change - COUCHDB-892 - remote-to-remote",
468469
"simple remote-to-remote replication - remote-to-remote",
469470
"source database not found with host",
470-
"unauthorized replication cancellation",
471471
"validate_doc_update failure replications - remote-to-remote"
472472
],
473473
"ReshardAllDocsTest": [
@@ -481,6 +481,9 @@
481481
"split q=2 shards on node1 (2 jobs)",
482482
"toggle global state"
483483
],
484+
"ReshardChangesFeedTest": [
485+
"all_docs after splitting all shards on node1"
486+
],
484487
"RevStemmingTest": [
485488
"revs limit is kept after compaction",
486489
"revs limit produces replication conflict ",
@@ -493,8 +496,8 @@
493496
"multiple updates with same _rev raise conflict errors"
494497
],
495498
"RewriteJSTest": [
496-
"Test basic js rewrites on test_rewrite_suite_db",
497-
"Test basic js rewrites on test_rewrite_suite_db%2Fwith_slashes",
499+
"basic js rewrites on test_rewrite_suite_db",
500+
"basic js rewrites on test_rewrite_suite_db%2Fwith_slashes",
498501
"early response on test_rewrite_suite_db",
499502
"early response on test_rewrite_suite_db%2Fwith_slashes",
500503
"loop on test_rewrite_suite_db",
@@ -505,8 +508,8 @@
505508
"requests with body preserve the query string rewrite on test_rewrite_suite_db%2Fwith_slashes"
506509
],
507510
"RewriteTest": [
508-
"Test basic rewrites on test_rewrite_suite_db",
509-
"Test basic rewrites on test_rewrite_suite_db%2Fwith_slashes",
511+
"basic rewrites on test_rewrite_suite_db",
512+
"basic rewrites on test_rewrite_suite_db%2Fwith_slashes",
510513
"loop detection on test_rewrite_suite_db",
511514
"loop detection on test_rewrite_suite_db%2Fwith_slashes",
512515
"path relative to server on test_rewrite_suite_db",
@@ -643,7 +646,8 @@
643646
"GET - invalid parameter combinations get rejected ",
644647
"POST - invalid parameter combinations get rejected ",
645648
"argument combinations",
646-
"dir works",
649+
"dir ascending works",
650+
"dir descending works",
647651
"empty keys",
648652
"keys in GET body (group)",
649653
"keys in GET parameters",
@@ -711,24 +715,24 @@
711715
"view update seq"
712716
],
713717
"WithQuorumTest": [
714-
"Attachments overriden quorum should return 202-Acepted",
718+
"Attachments overridden quorum should return 202-Accepted",
715719
"Attachments should return 201-Created",
716-
"Bulk docs overriden quorum should return 202-Acepted",
720+
"Bulk docs overridden quorum should return 202-Accepted",
717721
"Bulk docs should return 201-Created",
718722
"Copy doc should return 201-Created",
719723
"Creating-Updating/Deleting doc should return 201-Created/200-OK",
720-
"Creating-Updating/Deleting doc with overriden quorum should return 202-Acepted/200-OK",
721-
"Creating/Deleting DB should return 201-Created/202-Acepted"
724+
"Creating-Updating/Deleting doc with overridden quorum should return 202-Accepted/200-OK",
725+
"Creating/Deleting DB should return 201-Created/200-OK"
722726
],
723727
"WithoutQuorumTest": [
724-
"Attachments overriden quorum should return 201-Created",
725-
"Attachments should return 202-Acepted",
726-
"Bulk docs overriden quorum should return 201-Created",
727-
"Bulk docs should return 202-Acepted",
728-
"Copy doc should return 202-Acepted",
729-
"Creating-Updating/Deleting doc with overriden quorum should return 201-Created/200-OK",
730-
"Creating/Deleting DB should return 202-Acepted",
731-
"Creating/Updating/Deleting doc should return 202-Acepted"
728+
"Attachments overridden quorum should return 201-Created",
729+
"Attachments should return 201-Created",
730+
"Bulk docs overridden quorum should return 201-Created",
731+
"Bulk docs should return 201-Created",
732+
"Copy doc should return 201-Created",
733+
"Creating-Updating/Deleting doc with overridden quorum should return 201-Created/200-OK",
734+
"Creating/Deleting DB should return 201-Created/200-OK",
735+
"Creating/Updating/Deleting doc should return 201-Created/200-OK"
732736
],
733737
"BasicFindTest": [
734738
"simple find",
@@ -801,8 +805,6 @@
801805
"json range",
802806
"compound key",
803807
"sort",
804-
"sort fwd",
805-
"sort rev",
806808
"all docs range",
807809
"no index",
808810
"invalid operand",

0 commit comments

Comments
 (0)