From 282b96ddd9a84b740788c2358ec0f5fedafb7cc6 Mon Sep 17 00:00:00 2001 From: Noah Slater Date: Mon, 6 Jul 2009 00:33:50 +0000 Subject: trimmed trailing whitespace git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@791350 13f79535-47bb-0310-9956-ffa450edef68 --- test/couch_config_test.erl | 6 ++-- test/couch_config_writer_test.erl | 6 ++-- test/etap/010-file-basics.t | 14 ++++----- test/etap/011-file-headers.t | 39 ++++++++++++------------ test/etap/020-btree-basics.t | 8 ++--- test/etap/021-btree-reductions.t | 12 ++++---- test/etap/030-doc-from-json.t | 10 +++---- test/etap/031-doc-to-json.t | 4 +-- test/etap/040-util.t | 8 ++--- test/etap/050-stream.t | 8 ++--- test/etap/060-kt-merging.t | 10 +++---- test/etap/061-kt-missing-leaves.t | 2 +- test/etap/062-kt-remove-leaves.t | 10 +++---- test/etap/063-kt-get-leaves.t | 14 ++++----- test/etap/064-kt-counting.t | 6 ++-- test/etap/070-couch-db.t | 8 ++--- test/etap/080-config-get-set.t | 42 +++++++++++++------------- test/etap/081-config-override.t | 62 +++++++++++++++++++-------------------- test/etap/082-config-register.t | 12 ++++---- test/etap/083-config-no-files.t | 4 +-- test/etap/090-task-status.t | 18 ++++++------ test/etap/100-ref-counter.t | 8 ++--- test/query_server_spec.rb | 50 +++++++++++++++---------------- test/test.js | 6 ++-- 24 files changed, 183 insertions(+), 184 deletions(-) (limited to 'test') diff --git a/test/couch_config_test.erl b/test/couch_config_test.erl index faacd5fc..a02affc1 100644 --- a/test/couch_config_test.erl +++ b/test/couch_config_test.erl @@ -1,7 +1,7 @@ % couch_config module test suote % Set up test suite -% ?MODULE_test() returns a list of functions +% ?MODULE_test() returns a list of functions % that run the actual tests. couch_config_test() -> [ @@ -10,7 +10,7 @@ couch_config_test() -> % test functions - + store_strings() -> Filename = "test.ini", file:write_file(Filename, ""), @@ -26,7 +26,7 @@ store_strings() -> exit(Proc, kill), receive {'EXIT', Proc, _} -> ok end, - + % clean up file:delete(Filename), diff --git a/test/couch_config_writer_test.erl b/test/couch_config_writer_test.erl index aa88abeb..6fa87078 100644 --- a/test/couch_config_writer_test.erl +++ b/test/couch_config_writer_test.erl @@ -1,7 +1,7 @@ % couch_config_writer module test suote % Set up test suite -% ?MODULE_test() returns a list of functions +% ?MODULE_test() returns a list of functions % that run the actual tests. % todo, fix replace_existing_variable2 (i.e. reordering) couch_config_writer_test() -> @@ -186,12 +186,12 @@ run_operation_and_compare_results(Contents, Expect, Config) -> % call replace function [couch_config_writer:save_to_file(ConfigVar, Filename) || ConfigVar <- Config], - + % compare new file with expected file {ok, Result_} = file:read_file(Filename), Result = binary_to_list(Result_), % clean up % file:delete(Filename), - + Result = Expect. 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( diff --git a/test/query_server_spec.rb b/test/query_server_spec.rb index f4b124ca..4605ca1b 100644 --- a/test/query_server_spec.rb +++ b/test/query_server_spec.rb @@ -94,7 +94,7 @@ class OSProcessRunner end class QueryServerRunner < OSProcessRunner - + COMMANDS = {"js" => "#{COUCH_ROOT}/src/couchdb/couchjs #{COUCH_ROOT}/share/server/main.js" } def self.run_command @@ -159,7 +159,7 @@ functions = { var row; log("about to getRow " + typeof(getRow)); while(row = getRow()) { - send(row.key); + send(row.key); }; return "tail"; }; @@ -172,8 +172,8 @@ functions = { var row; log("about to getRow " + typeof(getRow)); while(row = getRow()) { - send(row.key); - send("eggs"); + send(row.key); + send("eggs"); }; return "tail"; }; @@ -186,7 +186,7 @@ functions = { send(req.q); var row; while(row = getRow()) { - send(row.key); + send(row.key); }; return "early"; }; @@ -199,11 +199,11 @@ functions = { send(req.q); var row, i=0; while(row = getRow()) { - send(row.key); + send(row.key); i += 1; if (i > 2) { return('early tail'); - } + } }; }; JS @@ -221,7 +221,7 @@ functions = { send("bacon") var row, i = 0; while(row = getRow()) { - send(row.key); + send(row.key); i += 1; if (i > 2) { return('early'); @@ -237,7 +237,7 @@ functions = { send(req.q); var row; while(row = getRow()) { - send(row.key); + send(row.key); }; return "tail"; }; @@ -254,7 +254,7 @@ describe "query server normal case" do @qs.close end it "should reset" do - @qs.run(["reset"]).should == true + @qs.run(["reset"]).should == true end it "should run map funs" do @qs.reset! @@ -285,7 +285,7 @@ describe "query server normal case" do @qs.run(["rereduce", [@fun], vs]).should == [true, [45]] end end - + # it "should validate" describe "validation" do before(:all) do @@ -299,35 +299,35 @@ describe "query server normal case" do @qs.run(["validate", @fun, {"bad" => true}, {}, {}]).should == {"forbidden"=>"bad doc"} end end - + describe "show" do before(:all) do @fun = functions["show-simple"][LANGUAGE] @qs.reset! end it "should show" do - @qs.rrun(["show", @fun, + @qs.rrun(["show", @fun, {:title => "Best ever", :body => "Doc body"}]) @qs.jsgets.should == ["resp", {"body" => "Best ever - Doc body"}] end end - + describe "show with headers" do before(:all) do @fun = functions["show-headers"][LANGUAGE] @qs.reset! end it "should show headers" do - @qs.rrun(["show", @fun, + @qs.rrun(["show", @fun, {:title => "Best ever", :body => "Doc body"}]) @qs.jsgets.should == ["resp", {"code"=>200,"headers" => {"X-Plankton"=>"Rusty"}, "body" => "Best ever - Doc body"}] end end - + # end # LIST TESTS # __END__ - + describe "raw list with headers" do before(:each) do @fun = functions["show-sends"][LANGUAGE] @@ -341,11 +341,11 @@ describe "query server normal case" do @qs.jsgets.should == ["end", ["tail"]] end end - + describe "list with rows" do before(:each) do @fun = functions["show-while-get-rows"][LANGUAGE] - @qs.run(["reset"]).should == true + @qs.run(["reset"]).should == true @qs.add_fun(@fun).should == true end it "should list em" do @@ -365,7 +365,7 @@ describe "query server normal case" do @qs.jsgets.should == ["end", ["tail"]] end end - + describe "should buffer multiple chunks sent for a single row." do before(:all) do @fun = functions["show-while-get-rows-multi-send"][LANGUAGE] @@ -400,7 +400,7 @@ describe "query server normal case" do @qs.run(["list_end"]).should == ["end" , ["early"]] end end - + describe "only goes to 2 list" do before(:all) do @fun = functions["list-chunky"][LANGUAGE] @@ -443,7 +443,7 @@ describe "query server that exits" do after(:each) do @qs.close end - + describe "old style list" do before(:each) do @fun = functions["list-old-style"][LANGUAGE] @@ -456,7 +456,7 @@ describe "query server that exits" do resp["reason"].should include("the list API has changed") end end - + describe "only goes to 2 list" do before(:each) do @fun = functions["list-capped"][LANGUAGE] @@ -473,7 +473,7 @@ describe "query server that exits" do should_have_exited @qs end end - + describe "raw list" do before(:each) do @fun = functions["list-raw"][LANGUAGE] @@ -486,5 +486,5 @@ describe "query server that exits" do @qs.run(["reset"])["error"].should == "query_server_error" should_have_exited @qs end - end + end end diff --git a/test/test.js b/test/test.js index f3990966..07988085 100644 --- a/test/test.js +++ b/test/test.js @@ -56,7 +56,7 @@ var HTTP = (function() { var body = parts.pop(); var header = parts.pop(); var headers = header.split(/\n/); - + var status = /HTTP\/1.\d (\d*)/.exec(header)[1]; return { responseText: body, @@ -83,7 +83,7 @@ var HTTP = (function() { HEAD : function(url, body, headers) { var st, urx = url, hx = (headers || null); st = headhttp(urx, hx); - return parseCurl(st); + return parseCurl(st); }, DELETE : function(url, body, headers) { var st, urx = url, hx = (headers || null); @@ -202,7 +202,7 @@ function runAllTestsConsole() { } else { numTests += 1; var testFun = couchTests[t]; - runTestConsole(testFun, debug); + runTestConsole(testFun, debug); } } p("Results: "+numFailures.toString() + " failures in "+numTests+" tests.") -- cgit v1.2.3