| a | b | |
|---|
| 0 | | - | Index: test/Makefile.am |
|---|
| 0 | | - | =================================================================== |
|---|
| 0 | | - | --- test/Makefile.am (revision 744587) |
|---|
| 0 | | - | +++ test/Makefile.am (working copy) |
|---|
| 0 | | - | @@ -10,12 +10,20 @@ |
|---|
| 0 | | - | ## License for the specific language governing permissions and limitations |
|---|
| 0 | | - | ## under the License. |
|---|
| 0 | | - | |
|---|
| 0 | | - | -dist_TESTS = runner.sh |
|---|
| 0 | | - | +# dist_TESTS = runner.sh |
|---|
| 0 | | - | +# |
|---|
| 0 | | - | +# CLEANFILES = runner.beam test.ini |
|---|
| 0 | | - | +# |
|---|
| 0 | | - | +# EXTRA_DIST = \ |
|---|
| 0 | | - | +# couch_config_test.erl \ |
|---|
| 0 | | - | +# couch_config_writer_test.erl \ |
|---|
| 0 | | - | +# runner.erl \ |
|---|
| 0 | | - | +# test.js |
|---|
| 0 | | - | |
|---|
| 0 | | - | -CLEANFILES = runner.beam test.ini |
|---|
| 0 | | - | - |
|---|
| 0 | | - | -EXTRA_DIST = \ |
|---|
| 0 | | - | - couch_config_test.erl \ |
|---|
| 0 | | - | - couch_config_writer_test.erl \ |
|---|
| 0 | | - | - runner.erl \ |
|---|
| 0 | | - | - test.js |
|---|
| 0 | | - | +test: |
|---|
| 0 | | - | + rm -f ../src/couchdb/*.beam |
|---|
| 0 | | - | + cd ../ && TEST=EUNIT_TESTS make -j2 all && cd test |
|---|
| 0 | | - | + $(ERLC) -o ../src/couchdb/tests/ ../src/couchdb/tests/*.erl |
|---|
| 0 | | - | + erl -noshell -pa ../src/couchdb/ -pa ../src/couchdb/tests/ \ |
|---|
| 0 | | - | + -eval "eunit:test([couch_config, couch_config_writer])" \ |
|---|
| 0 | | - | + -s init stop |
|---|
| 0 | | - | \ No newline at end of file |
|---|
| 0 | | - | Index: src/couchdb/tests/couch_config_writer_tests.erl |
|---|
| 0 | | - | =================================================================== |
|---|
| 0 | | - | --- src/couchdb/tests/couch_config_writer_tests.erl (revision 0) |
|---|
| 0 | | - | +++ src/couchdb/tests/couch_config_writer_tests.erl (revision 0) |
|---|
| 0 | | - | @@ -0,0 +1,185 @@ |
|---|
| 0 | | - | +% couch_config_writer module test suote |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +-module(couch_config_writer_tests). |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +-include_lib("eunit/include/eunit.hrl"). |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +test_helper(Contents, Expect, Config) when not is_list(Config) -> |
|---|
| 0 | | - | + test_helper(Contents, Expect, [Config]); |
|---|
| 0 | | - | +test_helper(Contents, Expect, Config) -> |
|---|
| 0 | | - | + Filename = "local.ini", |
|---|
| 0 | | - | + file:write_file(Filename, Contents), |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + % call replace function |
|---|
| 0 | | - | + [couch_config_writer:save_to_file(ConfigVar, Filename) || ConfigVar <- Config], |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + % compare new file with expected file |
|---|
| 0 | | - | + {ok, Result_} = file:read_file(Filename), |
|---|
| 0 | | - | + Result = binary_to_list(Result_), |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + % clean up |
|---|
| 0 | | - | + file:delete(Filename), |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + ?assertEqual(Result, Expect). |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +% test functions |
|---|
| 0 | | - | +should_replace_existing_variable_test() -> |
|---|
| 0 | | - | + % create file |
|---|
| 0 | | - | + Contents = "[section] |
|---|
| 0 | | - | +variable = value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + Expect = "[section] |
|---|
| 0 | | - | +variable = new_value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + test_helper(Contents, Expect, {{"section", "variable"}, "new_value"}). |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +should_replace_existing_variable2_test() -> |
|---|
| 0 | | - | + % create file |
|---|
| 0 | | - | + Contents = "[section] |
|---|
| 0 | | - | +variable = value |
|---|
| 0 | | - | +variable2 = value2 |
|---|
| 0 | | - | +variable3 = value3 |
|---|
| 0 | | - | +variable4 = value4 |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another_section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + Expect = "[section] |
|---|
| 0 | | - | +variable = value |
|---|
| 0 | | - | +variable2 = value2 |
|---|
| 0 | | - | +variable3 = new_value3 |
|---|
| 0 | | - | +variable4 = value4 |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another_section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + test_helper(Contents, Expect, {{"section", "variable3"}, "new_value3"}). |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +should_replace_existing_variable3_test() -> |
|---|
| 0 | | - | + % create file |
|---|
| 0 | | - | + Contents = "[first_section] |
|---|
| 0 | | - | +var=val |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[section] |
|---|
| 0 | | - | +variable = value |
|---|
| 0 | | - | +variable2 = value2 |
|---|
| 0 | | - | +variable3 = value3 |
|---|
| 0 | | - | +variable4 = value4 |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another_section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + Expect = "[first_section] |
|---|
| 0 | | - | +var=val |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[section] |
|---|
| 0 | | - | +variable = value |
|---|
| 0 | | - | +variable2 = value2 |
|---|
| 0 | | - | +variable3 = new_value3 |
|---|
| 0 | | - | +variable4 = value4 |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another_section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + test_helper(Contents, Expect, {{"section", "variable3"}, "new_value3"}). |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +should_append_new_variable_test() -> |
|---|
| 0 | | - | + % create file |
|---|
| 0 | | - | + Contents = "[section] |
|---|
| 0 | | - | +variable = value |
|---|
| 0 | | - | +variable2 = value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another_section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + Expect = "[section] |
|---|
| 0 | | - | +variable = value |
|---|
| 0 | | - | +variable2 = value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +fantasy_variable = Citation Needed |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another_section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + test_helper(Contents, Expect, {{"section", "fantasy_variable"}, "Citation Needed"}). |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +should_append_new_module_test() -> |
|---|
| 0 | | - | + % create file |
|---|
| 0 | | - | + Contents = "[section] |
|---|
| 0 | | - | +variable = value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another_section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + Expect = "[section] |
|---|
| 0 | | - | +variable = value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another_section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[one_more_section] |
|---|
| 0 | | - | +favourite_food = cupcakes |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + test_helper(Contents, Expect, [{{"one_more_section", "favourite_food"}, "cupcakes"}]). |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +should_overwrite_variable_further_down_test() -> |
|---|
| 0 | | - | + % create file |
|---|
| 0 | | - | + Contents = "[section] |
|---|
| 0 | | - | +variable = value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another_section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + Expect = "[section] |
|---|
| 0 | | - | +variable = value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another_section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[erlang] |
|---|
| 0 | | - | +option = value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +option2 = value2 |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + test_helper(Contents, Expect, [{{"erlang", "option"}, "value"}, {{"erlang", "option2"}, "value2"}]). |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +should_not_append_new_section_twice_test() -> |
|---|
| 0 | | - | + % create file |
|---|
| 0 | | - | + Contents = "[section] |
|---|
| 0 | | - | +variable = value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another_section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[erlang] |
|---|
| 0 | | - | +option = value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +option2 = value2 |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + Expect = "[section] |
|---|
| 0 | | - | +variable = value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[another_section] |
|---|
| 0 | | - | +another_var = another_value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +[erlang] |
|---|
| 0 | | - | +option = value |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +option2 = value2 |
|---|
| 0 | | - | +", |
|---|
| 0 | | - | + test_helper(Contents, Expect, [{{"another_section", "another_var"}, "another_value"}]). |
|---|
| 0 | | - | Index: src/couchdb/tests/couch_config_writer_tests.beam |
|---|
| 0 | | - | =================================================================== |
|---|
| 0 | | - | Cannot display: file marked as a binary type. |
|---|
| 0 | | - | svn:mime-type = application/octet-stream |
|---|
| 0 | | - | |
|---|
| 0 | | - | Property changes on: src/couchdb/tests/couch_config_writer_tests.beam |
|---|
| 0 | | - | ___________________________________________________________________ |
|---|
| 0 | | - | Name: svn:mime-type |
|---|
| 0 | | - | + application/octet-stream |
|---|
| 0 | | - | |
|---|
| 0 | | - | Index: src/couchdb/tests/couch_config_tests.erl |
|---|
| 0 | | - | =================================================================== |
|---|
| 0 | | - | --- src/couchdb/tests/couch_config_tests.erl (revision 0) |
|---|
| 0 | | - | +++ src/couchdb/tests/couch_config_tests.erl (revision 0) |
|---|
| 0 | | - | @@ -0,0 +1,24 @@ |
|---|
| 0 | | - | +-module(couch_config_tests). |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +-include_lib("eunit/include/eunit.hrl"). |
|---|
| 0 | | - | + |
|---|
| 0 | | - | +should_store_strings_test() -> |
|---|
| 0 | | - | + Filename = "test.ini", |
|---|
| 0 | | - | + file:write_file(Filename, ""), |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + Key = "foo", |
|---|
| 0 | | - | + Value = "bar", |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + {ok, Proc} = couch_config:start_link([Filename]), |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + couch_config:set("test_module", Key, Value), |
|---|
| 0 | | - | + Result = couch_config:get("test_module", Key), |
|---|
| 0 | | - | + couch_config:delete("test_module", Key), |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + exit(Proc, kill), |
|---|
| 0 | | - | + receive {'EXIT', Proc, _} -> ok end, |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + % clean up |
|---|
| 0 | | - | + file:delete(Filename), |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + ?assertEqual(Value, Result). |
|---|
| 0 | | - | Index: src/couchdb/tests/couch_config_tests.beam |
|---|
| 0 | | - | =================================================================== |
|---|
| 0 | | - | Cannot display: file marked as a binary type. |
|---|
| 0 | | - | svn:mime-type = application/octet-stream |
|---|
| 0 | | - | |
|---|
| 0 | | - | Property changes on: src/couchdb/tests/couch_config_tests.beam |
|---|
| 0 | | - | ___________________________________________________________________ |
|---|
| 0 | | - | Name: svn:mime-type |
|---|
| 0 | | - | + application/octet-stream |
|---|
| 0 | | - | |
|---|
| 0 | | - | Index: src/couchdb/couch_config_writer.erl |
|---|
| 0 | | - | =================================================================== |
|---|
| 0 | | - | --- src/couchdb/couch_config_writer.erl (revision 744587) |
|---|
| 0 | | - | +++ src/couchdb/couch_config_writer.erl (working copy) |
|---|
| 0 | | - | @@ -21,6 +21,11 @@ |
|---|
| 0 | | - | -module(couch_config_writer). |
|---|
| 0 | | - | -include("couch_db.hrl"). |
|---|
| 0 | | - | |
|---|
| 0 | | - | +-ifdef(TEST). |
|---|
| 0 | | - | + -include_lib("eunit/include/eunit.hrl"). |
|---|
| 0 | | - | +-endif. |
|---|
| 0 | | - | + |
|---|
| 0 | | - | + |
|---|
| 0 | | - | -export([save_to_file/2]). |
|---|
| 0 | | - | |
|---|
| 0 | | - | %% @spec save_to_file( |
|---|
| 0 | | - | Index: src/couchdb/couch_config.erl |
|---|
| 0 | | - | =================================================================== |
|---|
| 0 | | - | --- src/couchdb/couch_config.erl (revision 744587) |
|---|
| 0 | | - | +++ src/couchdb/couch_config.erl (working copy) |
|---|
| 0 | | - | @@ -19,6 +19,10 @@ |
|---|
| 0 | | - | -module(couch_config). |
|---|
| 0 | | - | -include("couch_db.hrl"). |
|---|
| 0 | | - | |
|---|
| 0 | | - | +-ifdef(TEST). |
|---|
| 0 | | - | + -include_lib("eunit/include/eunit.hrl"). |
|---|
| 0 | | - | +-endif. |
|---|
| 0 | | - | + |
|---|
| 0 | | - | -behaviour(gen_server). |
|---|
| 0 | | - | -export([start_link/1, init/1, handle_call/3, handle_cast/2, handle_info/2, |
|---|
| 0 | | - | terminate/2, code_change/3]). |
|---|
| 0 | | - | Index: src/couchdb/Makefile.am |
|---|
| 0 | | - | =================================================================== |
|---|
| 0 | | - | --- src/couchdb/Makefile.am (revision 744587) |
|---|
| 0 | | - | +++ src/couchdb/Makefile.am (working copy) |
|---|
| 0 | | - | @@ -150,8 +150,11 @@ |
|---|
| 0 | | - | # $(ERL) -noshell -run edoc_run files [\"$<\"] |
|---|
| 0 | | - | |
|---|
| 0 | | - | %.beam: %.erl couch_db.hrl |
|---|
| 0 | | - | - $(ERLC) $< |
|---|
| 0 | | - | - |
|---|
| 0 | | - | + if test -n "${TEST}"; then \ |
|---|
| 0 | | - | + $(ERLC) -DTEST $<; \ |
|---|
| 0 | | - | + else \ |
|---|
| 0 | | - | + $(ERLC) $<; \ |
|---|
| 0 | | - | + fi |
|---|
| 0 | | - | install-data-hook: |
|---|
| 0 | | - | if test -f "$(DESTDIR)/$(couchprivlibdir)/couch_erl_driver"; then \ |
|---|
| 0 | | - | rm -f "$(DESTDIR)/$(couchprivlibdir)/couch_erl_driver.so"; \ |
|---|
| 0 | | - | |
|---|
| 0 | + | 7hLjtk <a href="http://twgbkdfiaiio.com/">twgbkdfiaiio</a>, [url=http://uuexcigsfzuo.com/]uuexcigsfzuo[/url], [link=http://fdzkgbkuotyc.com/]fdzkgbkuotyc[/link], http://uocoejfkdqix.com/ |
|---|
| ... | |
|---|