diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_unlock_SUITE.erl | 40 | ||||
-rw-r--r-- | test/rebar_unlock_SUITE_data/rebar.lock | 40 |
2 files changed, 80 insertions, 0 deletions
diff --git a/test/rebar_unlock_SUITE.erl b/test/rebar_unlock_SUITE.erl new file mode 100644 index 0000000..31dca72 --- /dev/null +++ b/test/rebar_unlock_SUITE.erl @@ -0,0 +1,40 @@ +-module(rebar_unlock_SUITE). +-include_lib("common_test/include/ct.hrl"). +-include_lib("eunit/include/eunit.hrl"). +-compile(export_all). + +all() -> [unlock, unlock_all]. + +init_per_testcase(Case, Config0) -> + Config = rebar_test_utils:init_rebar_state(Config0, atom_to_list(Case)), + Lockfile = filename:join(?config(apps, Config), "rebar.lock"), + ec_file:copy(filename:join(?config(data_dir, Config), "rebar.lock"), + Lockfile), + [{lockfile, Lockfile} | Config]. + +end_per_testcase(_, Config) -> + Config. + +unlock(Config) -> + Locks = read_locks(Config), + rebar_test_utils:run_and_check(Config, [], ["unlock", "fakeapp"], {ok, []}), + Locks = read_locks(Config), + rebar_test_utils:run_and_check(Config, [], ["unlock", "uuid"], {ok, []}), + ?assertEqual(Locks -- ["uuid"], read_locks(Config)), + rebar_test_utils:run_and_check(Config, [], ["unlock", "gproc,itc"], {ok, []}), + ?assertEqual(Locks -- ["uuid","gproc","itc"], read_locks(Config)), + rebar_test_utils:run_and_check(Config, [], ["unlock", string:join(Locks,",")], {ok, []}), + ?assertEqual({error, enoent}, read_locks(Config)), + ok. + +unlock_all(Config) -> + [_|_] = read_locks(Config), + rebar_test_utils:run_and_check(Config, [], ["unlock"], {ok, []}), + ?assertEqual({error, enoent}, read_locks(Config)), + ok. + +read_locks(Config) -> + case file:consult(?config(lockfile, Config)) of + {ok, [Locks]} -> [binary_to_list(element(1,Lock)) || Lock <- Locks]; + Other -> Other + end. diff --git a/test/rebar_unlock_SUITE_data/rebar.lock b/test/rebar_unlock_SUITE_data/rebar.lock new file mode 100644 index 0000000..ab68d8e --- /dev/null +++ b/test/rebar_unlock_SUITE_data/rebar.lock @@ -0,0 +1,40 @@ +[{<<"meck">>, + {git,"git://github.com/eproxus/meck", + {ref,"69664df5d0e01a0ae27efb62831d6eea45cc1cd4"}}, + 3}, + {<<"itc">>, + {git,"git://github.com/ferd/Interval-Tree-Clocks.git", + {ref,"168449da42871892f6047733edddf33936dd660f"}}, + 2}, + {<<"bitcask">>, + {git,"https://github.com/basho/bitcask.git", + {ref,"c3e9cc5e64bcfd6e342a85932a90428cfdc1ee2d"}}, + 2}, + {<<"quickrand">>, + {git,"https://github.com/okeuday/quickrand.git", + {ref,"0395a10b94472ccbe38b62bbfa9d0fc1ddac1dd7"}}, + 1}, + {<<"merklet">>, + {git,"git://github.com/ferd/merklet.git", + {ref,"21b5797a21ab6aa1ddb6740799372d2d4b6a6054"}}, + 1}, + {<<"interclock">>, + {git,"git://github.com/ferd/interclock.git", + {ref,"6a8b7443fa200da16d819f058e4dc8a0a75eca1e"}}, + 1}, + {<<"gproc">>, + {git,"git://github.com/uwiger/gproc.git", + {ref,"7655bddc4397d0cc3f7c4d95e7b96790605946fe"}}, + 1}, + {<<"uuid">>, + {git,"https://github.com/okeuday/uuid.git", + {ref,"f7c141c8359cd690faba0d2684b449a07db8e915"}}, + 0}, + {<<"peeranha">>, + {git,"https://github.com/ferd/peeranha.git", + {ref,"3bdbdadf6e34a1705bf2669eb28acd32a4fc9166"}}, + 0}, + {<<"file_monitor">>, + {git,"https://github.com/richcarl/file_monitor.git", + {ref,"4910b991bf3166377985d7ed961665c4b24e3de6"}}, + 0}]. |