Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 78 lines (64 sloc) 2.822 kB
a3f1f55 @ngerakines Improving test coverage.
authored
1 #!/usr/bin/env escript
2 %% -*- erlang -*-
3 %%! -pa ./ebin
4
5 main(_) ->
8d25fd2 @ngerakines Updating TCC in document related functionality.
authored
6 etap:plan(14),
07b08c4 @ngerakines Committing changes from Erlang-Factory (improving test code coverage).
authored
7 pre_run(),
8 test(),
9 etap:end_tests(),
10 ok.
11
12 pre_run() ->
a3f1f55 @ngerakines Improving test coverage.
authored
13 {A1, A2, A3} = now(),
14 random:seed(A1, A2, A3),
15 ok.
16
17 database() ->
18 lists:flatten([
19 [[random:uniform(25) + 96] || _ <-lists:seq(1,5)],
20 [[random:uniform(9) + 47] || _ <-lists:seq(1,3)]
21 ]).
07b08c4 @ngerakines Committing changes from Erlang-Factory (improving test code coverage).
authored
22
23 test() ->
24 Database = database(),
25
26 (fun() ->
27 etap:is(erlang_couchdb:create_database({"localhost", 5984}, Database), ok, "tmp database created"),
28 {ok, DatabaseProps} = erlang_couchdb:database_info({"localhost", 5984}, Database),
29 etap:is(proplists:get_value(<<"db_name">>, DatabaseProps), list_to_binary(Database), "name ok"),
30 etap:is(proplists:get_value(<<"doc_count">>, DatabaseProps), 0, "document count ok"),
31 etap:is(proplists:get_value(<<"doc_del_count">>, DatabaseProps), 0, "document delete count ok"),
32 etap:is(proplists:get_value(<<"update_seq">>, DatabaseProps), 0, "update count ok"),
33 etap:is(proplists:get_value(<<"purge_seq">>, DatabaseProps), 0, "purge count ok"),
34 etap:is(proplists:get_value(<<"compact_running">>, DatabaseProps), false, "compaction status ok"),
35 ok
36 end)(),
37
38 (fun() ->
39 {ok, Databases} = erlang_couchdb:retrieve_all_dbs({"localhost", 5984}),
8d25fd2 @ngerakines Updating TCC in document related functionality.
authored
40 etap:any(list_to_binary(Database), Databases, "tmp database listed"),
07b08c4 @ngerakines Committing changes from Erlang-Factory (improving test code coverage).
authored
41 ok
42 end)(),
43
44 (fun() ->
8d25fd2 @ngerakines Updating TCC in document related functionality.
authored
45 etap:fun_is(fun ({error, _}) -> true; (_) -> false end, erlang_couchdb:retrieve_all_dbs({"example.com", 80}), "Triggering server 'other' response"),
46 ok
47 end)(),
48
49 (fun() ->
50 etap:fun_is(fun ({error, _}) -> true; (_) -> false end, erlang_couchdb:database_info({"example.com", 80}, "asdasdasd"), "Triggering server 'other' response"),
51 ok
52 end)(),
53
54 (fun() ->
55 Error = {ok,[{<<"error">>,<<"not_found">>}, {<<"reason">>,<<"Missing">>}]},
56 etap:is(erlang_couchdb:database_info({"localhost", 5984}, "hahahahano"), Error, "database_info/2 on non-existing db."),
57 ok
58 end)(),
59
60 (fun() ->
61 Error = {error,{json,{struct,[{<<"error">>,<<"file_exists">>}, {<<"reason">>, <<"The database could not be created, the file already exists.">>}]}}},
62 etap:is(erlang_couchdb:create_database({"localhost", 5984}, Database), Error, "tmp database created"),
63 ok
64 end)(),
65
66 (fun() ->
07b08c4 @ngerakines Committing changes from Erlang-Factory (improving test code coverage).
authored
67 etap:is(erlang_couchdb:delete_database({"localhost", 5984}, Database), ok, "tmp database created"),
68 ok
69 end)(),
70
8d25fd2 @ngerakines Updating TCC in document related functionality.
authored
71 (fun() ->
72 Error = {error,{json,{struct,[{<<"error">>,<<"not_found">>}, {<<"reason">>,<<"Missing">>}]}}},
73 etap:is(erlang_couchdb:delete_database({"localhost", 5984}, Database), Error, "tmp database created"),
74 ok
75 end)(),
76
07b08c4 @ngerakines Committing changes from Erlang-Factory (improving test code coverage).
authored
77 ok.
Something went wrong with that request. Please try again.