summaryrefslogtreecommitdiff
path: root/test/etap
diff options
context:
space:
mode:
authorNoah Slater <nslater@apache.org>2009-07-06 00:33:50 +0000
committerNoah Slater <nslater@apache.org>2009-07-06 00:33:50 +0000
commit282b96ddd9a84b740788c2358ec0f5fedafb7cc6 (patch)
treefb48e605ceb8079d0195d3b1ec0eca7110fa7ef2 /test/etap
parentb5cc085d3bc6316063f14adedf20632ee904875d (diff)
trimmed trailing whitespace
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@791350 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/etap')
-rwxr-xr-xtest/etap/010-file-basics.t14
-rwxr-xr-xtest/etap/011-file-headers.t39
-rwxr-xr-xtest/etap/020-btree-basics.t8
-rwxr-xr-xtest/etap/021-btree-reductions.t12
-rwxr-xr-xtest/etap/030-doc-from-json.t10
-rwxr-xr-xtest/etap/031-doc-to-json.t4
-rwxr-xr-xtest/etap/040-util.t8
-rwxr-xr-xtest/etap/050-stream.t8
-rwxr-xr-xtest/etap/060-kt-merging.t10
-rwxr-xr-xtest/etap/061-kt-missing-leaves.t2
-rwxr-xr-xtest/etap/062-kt-remove-leaves.t10
-rwxr-xr-xtest/etap/063-kt-get-leaves.t14
-rwxr-xr-xtest/etap/064-kt-counting.t6
-rwxr-xr-xtest/etap/070-couch-db.t8
-rwxr-xr-xtest/etap/080-config-get-set.t42
-rwxr-xr-xtest/etap/081-config-override.t62
-rwxr-xr-xtest/etap/082-config-register.t12
-rwxr-xr-xtest/etap/083-config-no-files.t4
-rwxr-xr-xtest/etap/090-task-status.t18
-rwxr-xr-xtest/etap/100-ref-counter.t8
20 files changed, 149 insertions, 150 deletions
diff --git a/test/etap/010-file-basics.t b/test/etap/010-file-basics.t
index 9033317f..055c9780 100755
--- a/test/etap/010-file-basics.t
+++ b/test/etap/010-file-basics.t
@@ -15,7 +15,7 @@ main(_) ->
etap:bail()
end,
ok.
-
+
test() ->
etap:is({error, enoent}, couch_file:open("not a real file"),
"Opening a non-existant file should return an enoent error."),
@@ -29,7 +29,7 @@ test() ->
{ok, Fd} = couch_file:open(filename() ++ ".0", [create, overwrite]),
etap:ok(is_pid(Fd),
"Returned file descriptor is a Pid"),
-
+
etap:is({ok, 0}, couch_file:bytes(Fd),
"Newly created files have 0 bytes."),
@@ -39,16 +39,16 @@ test() ->
{ok, Size} = couch_file:bytes(Fd),
etap:is_greater(Size, 0,
"Writing a term increased the file size."),
-
+
etap:is({ok, Size}, couch_file:append_binary(Fd, <<"fancy!">>),
"Appending a binary returns the current file size."),
-
+
etap:is({ok, foo}, couch_file:pread_term(Fd, 0),
"Reading the first term returns what we wrote: foo"),
-
+
etap:is({ok, <<"fancy!">>}, couch_file:pread_binary(Fd, Size),
"Reading back the binary returns what we wrote: <<\"fancy\">>."),
-
+
etap:is({ok, <<131, 100, 0, 3, 102, 111, 111>>},
couch_file:pread_binary(Fd, 0),
"Reading a binary at a term position returns the term as binary."
@@ -75,7 +75,7 @@ test() ->
% "Reading data that was truncated fails.")
etap:skip(fun() -> ok end,
"No idea how to test reading beyond EOF"),
-
+
etap:is({ok, foo}, couch_file:pread_term(Fd, 0),
"Truncating does not affect data located before the truncation mark."),
diff --git a/test/etap/011-file-headers.t b/test/etap/011-file-headers.t
index 83478d34..4ad3d21f 100755
--- a/test/etap/011-file-headers.t
+++ b/test/etap/011-file-headers.t
@@ -19,39 +19,39 @@ main(_) ->
etap:bail()
end,
ok.
-
+
test() ->
{ok, Fd} = couch_file:open(filename(), [create,overwrite]),
-
+
etap:is({ok, 0}, couch_file:bytes(Fd),
"File should be initialized to contain zero bytes."),
-
+
etap:is(ok, couch_file:write_header(Fd, {<<"some_data">>, 32}),
"Writing a header succeeds."),
-
+
{ok, Size1} = couch_file:bytes(Fd),
etap:is_greater(Size1, 0,
"Writing a header allocates space in the file."),
-
+
etap:is({ok, {<<"some_data">>, 32}}, couch_file:read_header(Fd),
"Reading the header returns what we wrote."),
-
+
etap:is(ok, couch_file:write_header(Fd, [foo, <<"more">>]),
"Writing a second header succeeds."),
-
+
{ok, Size2} = couch_file:bytes(Fd),
etap:is_greater(Size2, Size1,
"Writing a second header allocates more space."),
-
+
etap:is({ok, [foo, <<"more">>]}, couch_file:read_header(Fd),
"Reading the second header does not return the first header."),
-
+
% Delete the second header.
ok = couch_file:truncate(Fd, Size1),
-
+
etap:is({ok, {<<"some_data">>, 32}}, couch_file:read_header(Fd),
"Reading the header after a truncation returns a previous header."),
-
+
couch_file:write_header(Fd, [foo, <<"more">>]),
etap:is({ok, Size2}, couch_file:bytes(Fd),
"Rewriting the same second header returns the same second size."),
@@ -60,16 +60,16 @@ test() ->
% Now for the fun stuff. Try corrupting the second header and see
% if we recover properly.
-
+
% Destroy the 0x1 byte that marks a header
check_header_recovery(fun(CouchFd, RawFd, Expect, HeaderPos) ->
etap:isnt(Expect, couch_file:read_header(CouchFd),
"Should return a different header before corruption."),
file:pwrite(RawFd, HeaderPos, <<0>>),
etap:is(Expect, couch_file:read_header(CouchFd),
- "Corrupting the byte marker should read the previous header.")
+ "Corrupting the byte marker should read the previous header.")
end),
-
+
% Corrupt the size.
check_header_recovery(fun(CouchFd, RawFd, Expect, HeaderPos) ->
etap:isnt(Expect, couch_file:read_header(CouchFd),
@@ -79,7 +79,7 @@ test() ->
etap:is(Expect, couch_file:read_header(CouchFd),
"Corrupting the size should read the previous header.")
end),
-
+
% Corrupt the MD5 signature
check_header_recovery(fun(CouchFd, RawFd, Expect, HeaderPos) ->
etap:isnt(Expect, couch_file:read_header(CouchFd),
@@ -89,7 +89,7 @@ test() ->
etap:is(Expect, couch_file:read_header(CouchFd),
"Corrupting the MD5 signature should read the previous header.")
end),
-
+
% Corrupt the data
check_header_recovery(fun(CouchFd, RawFd, Expect, HeaderPos) ->
etap:isnt(Expect, couch_file:read_header(CouchFd),
@@ -99,7 +99,7 @@ test() ->
etap:is(Expect, couch_file:read_header(CouchFd),
"Corrupting the header data should read the previous header.")
end),
-
+
ok.
check_header_recovery(CheckFun) ->
@@ -112,9 +112,9 @@ check_header_recovery(CheckFun) ->
{ok, HeaderPos} = write_random_data(Fd),
ok = couch_file:write_header(Fd, {2342, <<"corruption! greed!">>}),
-
+
CheckFun(Fd, RawFd, {ok, ExpectHeader}, HeaderPos),
-
+
ok = file:close(RawFd),
ok = couch_file:close(Fd),
ok.
@@ -131,4 +131,3 @@ write_random_data(Fd, N) ->
{ok, _} = couch_file:append_term(Fd, Term),
write_random_data(Fd, N-1).
- \ No newline at end of file
diff --git a/test/etap/020-btree-basics.t b/test/etap/020-btree-basics.t
index fbc895c1..1b985a4a 100755
--- a/test/etap/020-btree-basics.t
+++ b/test/etap/020-btree-basics.t
@@ -29,7 +29,7 @@ test()->
etap:ok(test_kvs(shuffle(Sorted)), "Testing shuffled keys."),
ok.
-test_kvs(KeyValues) ->
+test_kvs(KeyValues) ->
ReduceFun = fun
(reduce, KVs) ->
length(KVs);
@@ -53,7 +53,7 @@ test_kvs(KeyValues) ->
{ok, Btree2} = couch_btree:add_remove(Btree1, KeyValues, []),
etap:ok(test_btree(Btree2, KeyValues),
"Adding all keys at once returns a complete btree."),
-
+
etap:fun_is(
fun
({ok, {kp_node, _}}) -> true;
@@ -98,7 +98,7 @@ test_kvs(KeyValues) ->
etap:ok(test_add_remove(Btree6, Rem2Keys0, Rem2Keys1),
"Add/Remove every other key."),
-
+
etap:ok(test_add_remove(Btree6, Rem2Keys1, Rem2Keys0),
"Add/Remove opposite every other key."),
@@ -189,5 +189,5 @@ randomize(List) ->
D = lists:map(fun(A) ->
{random:uniform(), A}
end, List),
- {_, D1} = lists:unzip(lists:keysort(1, D)),
+ {_, D1} = lists:unzip(lists:keysort(1, D)),
D1.
diff --git a/test/etap/021-btree-reductions.t b/test/etap/021-btree-reductions.t
index 9ae7dbbf..d2de4c92 100755
--- a/test/etap/021-btree-reductions.t
+++ b/test/etap/021-btree-reductions.t
@@ -22,10 +22,10 @@ test()->
(reduce, KVs) -> length(KVs);
(rereduce, Reds) -> lists:sum(Reds)
end,
-
+
{ok, Fd} = couch_file:open(filename(), [create,overwrite]),
{ok, Btree} = couch_btree:open(nil, Fd, [{reduce, ReduceFun}]),
-
+
% Create a list, of {"even", Value} or {"odd", Value} pairs.
{_, EvenOddKVs} = lists:foldl(fun(Idx, {Key, Acc}) ->
case Key of
@@ -50,7 +50,7 @@ test()->
true;
(_) ->
false
- end,
+ end,
couch_btree:fold_reduce(Btree2, nil, nil, GroupFun, FoldFun, []),
"Reduction works with no specified direction, startkey, or endkey."
),
@@ -76,7 +76,7 @@ test()->
couch_btree:fold_reduce(Btree2, rev, nil, nil, GroupFun, FoldFun, []),
"Reducing backwards works with no startkey or endkey."
),
-
+
etap:fun_is(
fun
({ok, [{{"odd", _}, 500}, {{"even", _}, 500}]}) ->
@@ -87,7 +87,7 @@ test()->
couch_btree:fold_reduce(Btree2, fwd, SK1, EK2, GroupFun, FoldFun, []),
"Reducing works over the entire range with startkey and endkey set."
),
-
+
etap:fun_is(
fun
({ok, [{{"even", _}, 500}]}) -> true;
@@ -114,7 +114,7 @@ test()->
couch_btree:fold_reduce(Btree2, rev, EK2, SK2, GroupFun, FoldFun, []),
"Reducing in reverse works after swapping the startkey and endkey."
),
-
+
etap:fun_is(
fun
({ok, [{{"even", _}, 500}, {{"odd", _}, 500}]}) ->
diff --git a/test/etap/030-doc-from-json.t b/test/etap/030-doc-from-json.t
index 242591ed..431aa7ed 100755
--- a/test/etap/030-doc-from-json.t
+++ b/test/etap/030-doc-from-json.t
@@ -18,7 +18,7 @@ main(_) ->
etap:bail()
end,
ok.
-
+
test() ->
ok = test_from_json_success(),
ok = test_from_json_errors(),
@@ -49,7 +49,7 @@ test_from_json_success() ->
{
{[{<<"_rev">>, <<"4-230234">>}]},
#doc{revs={4, [<<"230234">>]}},
- "_rev stored in revs."
+ "_rev stored in revs."
},
{
{[{<<"soap">>, 35}]},
@@ -105,7 +105,7 @@ test_from_json_success() ->
{
{[{<<"_local_seq">>, dropping}]},
#doc{},
- "Drops _local_seq."
+ "Drops _local_seq."
},
{
{[{<<"_conflicts">>, dropping}]},
@@ -118,7 +118,7 @@ test_from_json_success() ->
"Drops _deleted_conflicts."
}
],
-
+
lists:foreach(fun({EJson, Expect, Mesg}) ->
etap:is(couch_doc:from_json_obj(EJson), Expect, Mesg)
end, Cases),
@@ -193,7 +193,7 @@ test_from_json_errors() ->
"Underscore prefix fields are reserved."
}
],
-
+
lists:foreach(fun
({EJson, Expect, Mesg}) ->
Error = (catch couch_doc:from_json_obj(EJson)),
diff --git a/test/etap/031-doc-to-json.t b/test/etap/031-doc-to-json.t
index 37ee9946..9bb5747e 100755
--- a/test/etap/031-doc-to-json.t
+++ b/test/etap/031-doc-to-json.t
@@ -22,7 +22,7 @@ main(_) ->
test() ->
ok = test_to_json_success(),
ok.
-
+
test_to_json_success() ->
Cases = [
{
@@ -92,7 +92,7 @@ test_to_json_success() ->
{
#doc{meta=[{deleted_conflicts, [{10923, <<"big_cowboy_hat">>}]}]},
{[
- {<<"_id">>, <<>>},
+ {<<"_id">>, <<>>},
{<<"_deleted_conflicts">>, [<<"10923-big_cowboy_hat">>]}
]},
"_deleted_conflicsts is added as an array of strings."
diff --git a/test/etap/040-util.t b/test/etap/040-util.t
index a6b7df33..94db4534 100755
--- a/test/etap/040-util.t
+++ b/test/etap/040-util.t
@@ -19,13 +19,13 @@ test() ->
% to_existing_atom
etap:is(true, couch_util:to_existing_atom(true), "An atom is an atom."),
etap:is(foo, couch_util:to_existing_atom(<<"foo">>),
- "A binary foo is the atom foo."),
+ "A binary foo is the atom foo."),
etap:is(foobarbaz, couch_util:to_existing_atom("foobarbaz"),
"A list of atoms is one munged atom."),
% terminate_linked
Self = self(),
- spawn(fun() ->
+ spawn(fun() ->
ChildPid = spawn_link(fun() -> receive shutdown -> ok end end),
couch_util:terminate_linked(normal),
Self ! {pid, ChildPid}
@@ -33,7 +33,7 @@ test() ->
receive
{pid, Pid} ->
etap:ok(not is_process_alive(Pid), "why wont this work?")
- end,
+ end,
% new_uuid
etap:isnt(couch_util:new_uuid(), couch_util:new_uuid(),
@@ -68,5 +68,5 @@ test() ->
etap:ok(not couch_util:should_flush(),
"Checking to flush invokes GC."),
-
+
ok.
diff --git a/test/etap/050-stream.t b/test/etap/050-stream.t
index dab2d50c..bb28a96b 100755
--- a/test/etap/050-stream.t
+++ b/test/etap/050-stream.t
@@ -20,7 +20,7 @@ read_all(Fd, PosList) ->
test() ->
{ok, Fd} = couch_file:open("test/etap/temp.050", [create,overwrite]),
{ok, Stream} = couch_stream:open(Fd),
-
+
etap:is(ok, couch_stream:write(Stream, <<"food">>),
"Writing to streams works."),
@@ -43,16 +43,16 @@ test() ->
"Successfully wrote 80 1 bits."),
ZeroBits = <<0:(8*10)>>,
- etap:is(ok, couch_stream:write(Stream2, ZeroBits),
+ etap:is(ok, couch_stream:write(Stream2, ZeroBits),
"Successfully wrote 80 0 bits."),
-
+
{Ptrs2, Length2} = couch_stream:close(Stream2),
etap:is(Ptrs2, [ExpPtr], "Closing stream returns the file pointers."),
etap:is(Length2, 20, "Length written is 160 bytes."),
AllBits = iolist_to_binary([OneBits,ZeroBits]),
etap:is(AllBits, read_all(Fd, Ptrs2), "Returned pointers are valid."),
-
+
% Stream more the 4K chunk size.
{ok, ExpPtr2} = couch_file:bytes(Fd),
{ok, Stream3} = couch_stream:open(Fd),
diff --git a/test/etap/060-kt-merging.t b/test/etap/060-kt-merging.t
index 004e004f..f5d9fbe7 100755
--- a/test/etap/060-kt-merging.t
+++ b/test/etap/060-kt-merging.t
@@ -28,7 +28,7 @@ test() ->
Stemmed1a = [{1, {"1a", "bar", [{"1aa", "bar", []}]}}],
Stemmed1aa = [{2, {"1aa", "bar", []}}],
Stemmed1bb = [{2, {"1bb", "boo", []}}],
-
+
etap:is(
{EmptyTree, no_conflicts},
couch_key_tree:merge(EmptyTree, EmptyTree),
@@ -69,7 +69,7 @@ test() ->
{TwoChildSibs, no_conflicts},
couch_key_tree:merge(TwoChildSibs, TwoChildSibs),
"Merging a tree to itself is itself."),
-
+
etap:is(
{TwoChildSibs, no_conflicts},
couch_key_tree:merge(TwoChildSibs, Stemmed1b),
@@ -87,7 +87,7 @@ test() ->
couch_key_tree:merge(TwoChildSibs2, Stemmed1bb),
"Merging a stem at a deeper level."
),
-
+
etap:is(
{TwoChildSibs2, no_conflicts},
couch_key_tree:merge(Stemmed1bb, TwoChildSibs2),
@@ -118,11 +118,11 @@ test() ->
couch_key_tree:merge(OneChild, Stemmed1aa),
"Merging should create conflicts."
),
-
+
etap:is(
{TwoChild, no_conflicts},
couch_key_tree:merge(Expect1, TwoChild),
"Merge should have no conflicts."
),
-
+
ok.
diff --git a/test/etap/061-kt-missing-leaves.t b/test/etap/061-kt-missing-leaves.t
index c5ee1222..85fac0b6 100755
--- a/test/etap/061-kt-missing-leaves.t
+++ b/test/etap/061-kt-missing-leaves.t
@@ -17,7 +17,7 @@ test() ->
TwoChildSibs = [{0, {"1","foo", [{"1a", "bar", []}, {"1b", "bar", []}]}}],
Stemmed1 = [{1, {"1a", "bar", [{"1aa", "bar", []}]}}],
Stemmed2 = [{2, {"1aa", "bar", []}}],
-
+
etap:is(
[],
couch_key_tree:find_missing(TwoChildSibs, [{0,"1"}, {1,"1a"}]),
diff --git a/test/etap/062-kt-remove-leaves.t b/test/etap/062-kt-remove-leaves.t
index 566efa06..e560c6a9 100755
--- a/test/etap/062-kt-remove-leaves.t
+++ b/test/etap/062-kt-remove-leaves.t
@@ -23,31 +23,31 @@ test() ->
couch_key_tree:remove_leafs(TwoChildSibs, []),
"Removing no leaves has no effect on the tree."
),
-
+
etap:is(
{TwoChildSibs, []},
couch_key_tree:remove_leafs(TwoChildSibs, [{0, "1"}]),
"Removing a non-existant branch has no effect."
),
-
+
etap:is(
{OneChild, [{1, "1b"}]},
couch_key_tree:remove_leafs(TwoChildSibs, [{1, "1b"}]),
"Removing a leaf removes the leaf."
),
-
+
etap:is(
{[], [{1, "1b"},{1, "1a"}]},
couch_key_tree:remove_leafs(TwoChildSibs, [{1, "1a"}, {1, "1b"}]),
"Removing all leaves returns an empty tree."
),
-
+
etap:is(
{Stemmed, []},
couch_key_tree:remove_leafs(Stemmed, [{1, "1a"}]),
"Removing a non-existant node has no effect."
),
-
+
etap:is(
{[], [{2, "1aa"}]},
couch_key_tree:remove_leafs(Stemmed, [{2, "1aa"}]),
diff --git a/test/etap/063-kt-get-leaves.t b/test/etap/063-kt-get-leaves.t
index 9e366ff8..342657bf 100755
--- a/test/etap/063-kt-get-leaves.t
+++ b/test/etap/063-kt-get-leaves.t
@@ -22,7 +22,7 @@ test() ->
couch_key_tree:get(TwoChildSibs, [{0, "1"}]),
"extract a subtree."
),
-
+
etap:is(
{[{"bar", {1, ["1a", "1"]}}],[]},
couch_key_tree:get(TwoChildSibs, [{1, "1a"}]),
@@ -34,13 +34,13 @@ test() ->
couch_key_tree:get_key_leafs(TwoChildSibs, [{0, "x"}]),
"gather up the leaves."
),
-
+
etap:is(
{[{"bar", {1, ["1a","1"]}}],[]},
couch_key_tree:get_key_leafs(TwoChildSibs, [{1, "1a"}]),
"gather up the leaves."
),
-
+
etap:is(
{[{"bar", {1, ["1a","1"]}},{"bar",{1, ["1b","1"]}}],[]},
couch_key_tree:get_key_leafs(TwoChildSibs, [{0, "1"}]),
@@ -52,7 +52,7 @@ test() ->
couch_key_tree:get_full_key_paths(TwoChildSibs, [{0, "1"}]),
"retrieve full key paths."
),
-
+
etap:is(
{[{1,[{"1a", "bar"},{"1", "foo"}]}],[]},
couch_key_tree:get_full_key_paths(TwoChildSibs, [{1, "1a"}]),
@@ -64,19 +64,19 @@ test() ->
couch_key_tree:get_all_leafs_full(Stemmed),
"retrieve all leaves."
),
-
+
etap:is(
[{1, [{"1a", "bar"},{"1", "foo"}]}, {1, [{"1b", "bar"},{"1", "foo"}]}],
couch_key_tree:get_all_leafs_full(TwoChildSibs),
"retrieve all the leaves."
),
-
+
etap:is(
[{"bar", {2, ["1aa","1a"]}}],
couch_key_tree:get_all_leafs(Stemmed),
"retrieve all leaves."
),
-
+
etap:is(
[{"bar", {1, ["1a", "1"]}}, {"bar", {1, ["1b","1"]}}],
couch_key_tree:get_all_leafs(TwoChildSibs),
diff --git a/test/etap/064-kt-counting.t b/test/etap/064-kt-counting.t
index dd00cedd..aa42fec6 100755
--- a/test/etap/064-kt-counting.t
+++ b/test/etap/064-kt-counting.t
@@ -18,7 +18,7 @@ test() ->
One = [{0, {"1","foo",[]}}],
TwoChildSibs = [{0, {"1","foo", [{"1a", "bar", []}, {"1b", "bar", []}]}}],
Stemmed = [{2, {"1bb", "boo", []}}],
-
+
etap:is(0, couch_key_tree:count_leafs(EmptyTree),
"Empty trees have no leaves."),
@@ -27,8 +27,8 @@ test() ->
etap:is(2, couch_key_tree:count_leafs(TwoChildSibs),
"Two children siblings counted as two leaves."),
-
+
etap:is(1, couch_key_tree:count_leafs(Stemmed),
"Stemming does not affect leaf counting."),
-
+
ok.
diff --git a/test/etap/070-couch-db.t b/test/etap/070-couch-db.t
index 76519a55..d0ae0a52 100755
--- a/test/etap/070-couch-db.t
+++ b/test/etap/070-couch-db.t
@@ -4,7 +4,7 @@
main(_) ->
code:add_pathz("src/couchdb"),
code:add_pathz("src/mochiweb"),
-
+
etap:plan(4),
case (catch test()) of
ok ->
@@ -16,7 +16,7 @@ main(_) ->
ok.
test() ->
-
+
couch_server:start(
["etc/couchdb/default_dev.ini", "etc/couchdb/local_dev.ini"]
),
@@ -48,7 +48,7 @@ test() ->
Acc+1
end, 0, lists:seq(1, 200)),
etap:is(200, NumCreated, "Created all databases."),
-
+
lists:foreach(fun(Int) ->
ok = couch_server:delete(MkDbName(Int), [])
end, lists:seq(1, 200)),
@@ -59,5 +59,5 @@ test() ->
Acc+1
end, 0, lists:seq(1, 200)),
etap:is(200, NumDeleted, "Deleted all databases."),
-
+
ok.
diff --git a/test/etap/080-config-get-set.t b/test/etap/080-config-get-set.t
index 8cd6a9e6..7abd8a0a 100755
--- a/test/etap/080-config-get-set.t
+++ b/test/etap/080-config-get-set.t
@@ -19,23 +19,23 @@ main(_) ->
test() ->
% start couch_config with default
couch_config:start_link([default_config()]),
-
-
+
+
% Check that we can get values
-
-
+
+
etap:fun_is(
fun(List) -> length(List) > 0 end,
couch_config:all(),
"Data was loaded from the INI file."
),
-
+
etap:fun_is(
fun(List) -> length(List) > 0 end,
couch_config:get("daemons"),
"There are settings in the [daemons] section of the INI file."
),
-
+
etap:is(
couch_config:get("httpd_design_handlers", "_view"),
"{couch_httpd_view, handle_view_req}",
@@ -47,13 +47,13 @@ test() ->
"bar",
"Returns the default when key doesn't exist in config."
),
-
+
etap:is(
couch_config:get("httpd", "foo"),
undefined,
"The default default is the atom 'undefined'."
),
-
+
etap:is(
couch_config:get("httpd", "port", "bar"),
"5984",
@@ -63,43 +63,43 @@ test() ->
% Check that setting values works.
-
+
ok = couch_config:set("log", "level", "severe", false),
-
+
etap:is(
couch_config:get("log", "level"),
"severe",
"Non persisted changes take effect."
),
-
+
etap:is(
couch_config:get("new_section", "bizzle"),
undefined,
"Section 'new_section' does not exist."
),
-
+
ok = couch_config:set("new_section", "bizzle", "bang", false),
-
+
etap:is(
couch_config:get("new_section", "bizzle"),
"bang",
"New section 'new_section' was created for a new key/value pair."
),
-
-
+
+
% Check that deleting works
-
-
+
+
ok = couch_config:delete("new_section", "bizzle", false),
etap:is(
couch_config:get("new_section", "bizzle"),
"",
"Deleting sets the value to \"\""
),
-
-
+
+
% Check ge/set/delete binary strings
-
+
ok = couch_config:set(<<"foo">>, <<"bar">>, <<"baz">>, false),
etap:is(
couch_config:get(<<"foo">>, <<"bar">>),
@@ -112,5 +112,5 @@ test() ->
"",
"Deleting with binary section/key pairs sets the value to \"\""
),
-
+
ok.
diff --git a/test/etap/081-config-override.t b/test/etap/081-config-override.t
index bf9655f1..abb88854 100755
--- a/test/etap/081-config-override.t
+++ b/test/etap/081-config-override.t
@@ -29,7 +29,7 @@ run_tests(IniFiles, Tests) ->
main(_) ->
code:add_pathz("src/couchdb"),
etap:plan(17),
-
+
case (catch test()) of
ok ->
etap:end_tests();
@@ -50,42 +50,42 @@ test() ->
"100",
"{couchdb, max_dbs_open} is 100 by defualt."
),
-
+
etap:is(
couch_config:get("httpd","port"),
"5984",
"{httpd, port} is 5984 by default"
),
-
+
etap:is(
couch_config:get("fizbang", "unicode"),
undefined,
"{fizbang, unicode} is undefined by default"
)
end,
-
+
run_tests([default_config()], CheckDefaults),
-
-
+
+
% Check that subsequent files override values appropriately
-
+
CheckOverride = fun() ->
etap:is(
couch_config:get("couchdb", "max_dbs_open"),
"10",
"{couchdb, max_dbs_open} was overriden with the value 10"
),
-
+
etap:is(
couch_config:get("httpd", "port"),
"4895",
"{httpd, port} was overriden with the value 4895"
)
end,
-
+
run_tests([default_config(), local_config_1()], CheckOverride),
-
-
+
+
% Check that overrides can create new sections
CheckOverride2 = fun() ->
@@ -94,19 +94,19 @@ test() ->
"80",
"{httpd, port} is overriden with the value 80"
),
-
+
etap:is(
couch_config:get("fizbang", "unicode"),
"normalized",
"{fizbang, unicode} was created by override INI file"
)
end,
-
+
run_tests([default_config(), local_config_2()], CheckOverride2),
-
-
+
+
% Check that values can be overriden multiple times
-
+
CheckOverride3 = fun() ->
etap:is(
couch_config:get("httpd", "port"),
@@ -114,19 +114,19 @@ test() ->
"{httpd, port} value was taken from the last specified INI file."
)
end,
-
+
run_tests(
[default_config(), local_config_1(), local_config_2()],
CheckOverride3
),
% Check persistence to last file.
-
+
% Empty the file in case it exists.
{ok, Fd} = file:open(local_config_write(), write),
ok = file:truncate(Fd),
ok = file:close(Fd),
-
+
% Open and write a value
CheckCanWrite = fun() ->
etap:is(
@@ -134,34 +134,34 @@ test() ->
"5984",
"{httpd, port} is still 5984 by default"
),
-
+
etap:is(
couch_config:set("httpd", "port", "8080"),
ok,
"Writing {httpd, port} is kosher."
),
-
+
etap:is(
couch_config:get("httpd", "port"),
"8080",
"{httpd, port} was updated to 8080 successfully."
),
-
+
etap:is(
couch_config:delete("httpd", "bind_address"),
ok,
"Deleting {httpd, bind_address} succeeds"
),
-
+
etap:is(
couch_config:get("httpd", "bind_address"),
"",
"{httpd, bind_address} was actually deleted."
)
end,
-
+
run_tests([default_config(), local_config_write()], CheckCanWrite),
-
+
% Open and check where we don't expect persistence.
CheckDidntWrite = fun() ->
@@ -170,16 +170,16 @@ test() ->
"5984",
"{httpd, port} was not persisted to the primary INI file."
),
-
+
etap:is(
couch_config:get("httpd", "bind_address"),
"127.0.0.1",
"{httpd, bind_address} was not deleted form the primary INI file."
)
end,
-
+
run_tests([default_config()], CheckDidntWrite),
-
+
% Open and check we have only the persistence we expect.
CheckDidWrite = fun() ->
etap:is(
@@ -187,14 +187,14 @@ test() ->
"8080",
"{httpd, port} is still 8080 after reopening the config."
),
-
+
etap:is(
couch_config:get("httpd", "bind_address"),
"",
"{httpd, bind_address} is still \"\" after reopening."
)
end,
-
+
run_tests([local_config_write()], CheckDidWrite),
-
+
ok.
diff --git a/test/etap/082-config-register.t b/test/etap/082-config-register.t
index b64e2d9c..09972c9e 100755
--- a/test/etap/082-config-register.t
+++ b/test/etap/082-config-register.t
@@ -24,9 +24,9 @@ test() ->
"5984",
"{httpd, port} is 5984 by default."
),
-
+
ok = couch_config:set("httpd", "port", "4895", false),
-
+
etap:is(
couch_config:get("httpd", "port"),
"4895",
@@ -46,9 +46,9 @@ test() ->
end,
SentinelPid
),
-
+
ok = couch_config:set("httpd", "port", "8080", false),
-
+
% Implicitly checking that we *don't* call the function
etap:is(
couch_config:get("httpd", "bind_address"),
@@ -56,7 +56,7 @@ test() ->
"{httpd, bind_address} is not '0.0.0.0'"
),
ok = couch_config:set("httpd", "bind_address", "0.0.0.0", false),
-
+
% Ping-Pong kill process
SentinelPid ! {ping, self()},
receive
@@ -71,5 +71,5 @@ test() ->
"80",
"Implicitly test that the function got de-registered"
),
-
+
ok.
diff --git a/test/etap/083-config-no-files.t b/test/etap/083-config-no-files.t
index 28931d85..61ad9517 100755
--- a/test/etap/083-config-no-files.t
+++ b/test/etap/083-config-no-files.t
@@ -24,9 +24,9 @@ test() ->
couch_config:all(),
"No INI files specified returns 0 key/value pairs."
),
-
+
ok = couch_config:set("httpd", "port", "80", false),
-
+
etap:is(
couch_config:get("httpd", "port"),
"80",
diff --git a/test/etap/090-task-status.t b/test/etap/090-task-status.t
index 45d38dff..bc4c20ca 100755
--- a/test/etap/090-task-status.t
+++ b/test/etap/090-task-status.t
@@ -59,11 +59,11 @@ wait(Pid) ->
{ok, Pid, Msg} -> Msg
after 1000 ->
throw(timeout_error)
- end.
+ end.
-test() ->
+test() ->
{ok, TaskStatusPid} = couch_task_status:start_link(),
-
+
TaskUpdater = fun() -> loop() end,
% create three updaters
Pid1 = spawn(TaskUpdater),
@@ -103,13 +103,13 @@ test() ->
2,
"Started a second task."
),
-
+
etap:is(
check_status(Pid2, couch_task_status:all()),
<<"init">>,
"Second tasks's status was set to 'init'."
),
-
+
call(Pid2, update, "running"),
etap:is(
check_status(Pid2, couch_task_status:all()),
@@ -124,13 +124,13 @@ test() ->
3,
"Registered a third task."
),
-
+
etap:is(
check_status(Pid3, couch_task_status:all()),
<<"init">>,
"Third tasks's status was set to 'init'."
),
-
+
call(Pid3, update, "running"),
etap:is(
check_status(Pid3, couch_task_status:all()),
@@ -169,14 +169,14 @@ test() ->
2,
"First task finished."
),
-
+
call(Pid2, done),
etap:is(
length(couch_task_status:all()),
1,
"Second task finished."
),
-
+
call(Pid3, done),
etap:is(
length(couch_task_status:all()),
diff --git a/test/etap/100-ref-counter.t b/test/etap/100-ref-counter.t
index 746b70a9..144a95b8 100755
--- a/test/etap/100-ref-counter.t
+++ b/test/etap/100-ref-counter.t
@@ -26,9 +26,9 @@ wait() ->
after
1000 ->
throw(timeout_error)
- end.
+ end.
-test() ->
+test() ->
{ok, RefCtr} = couch_ref_counter:start([]),
etap:is(
@@ -67,7 +67,7 @@ test() ->
2,
"Droping the doubly added Pid only removes a ref, not a referer."
),
-
+
couch_ref_counter:drop(RefCtr, ChildPid1),
etap:is(
couch_ref_counter:count(RefCtr),
@@ -81,7 +81,7 @@ test() ->
2,
"Sanity checking that the Pid was re-added."
),
-
+
ChildPid1 ! {ping, self()},
wait(),
etap:is(