diff --git a/test/test.cfg b/test/test.cfg new file mode 100644 index 0000000..c0ace9e --- /dev/null +++ b/test/test.cfg @@ -0,0 +1,13 @@ +--- +config: + key: test@test-mpw.org + share_keys: + lang: en + file_gpg: "test.gpg" + sync_type: mpw + sync_host: + sync_port: + sync_user: + sync_pwd: + sync_path: + last_update: diff --git a/test/test.rb b/test/test.rb new file mode 100644 index 0000000..0f03d1b --- /dev/null +++ b/test/test.rb @@ -0,0 +1,45 @@ +# File: tc_simple_number.rb + +require_relative "../lib/MPW" +require "test/unit" + +class TestMPW < Test::Unit::TestCase + + + def test_initialize + File.delete('test.gpg') if File.exist?('test.gpg') + end + + def test_load_empty_file + mpw = MPW::MPW.new('test.cfg') + mpw.decrypt + + assert_equal(0, mpw.search.length) + end + + def test_add + mpw = MPW::MPW.new('test.cfg') + + name = 'test_name' + group = 'test_group' + host = 'test_host' + protocol = 'test_protocol' + login = 'test_login' + password = 'test_password' + port = '42' + comment = 'test_comment' + + mpw.update(name, group, host, protocol, login, password, port, comment) + + assert_equal(1, mpw.search.length) + assert_equal('test_name', mpw.search[0]['name']) + assert_equal('test_group', mpw.search[0]['group']) + assert_equal('test_host', mpw.search[0]['host']) + assert_equal('test_protocol', mpw.search[0]['protocol']) + assert_equal('test_login', mpw.search[0]['login']) + assert_equal('test_password', mpw.search[0]['password']) + assert_equal(42, mpw.search[0]['port']) + assert_equal('test_comment', mpw.search[0]['comment']) + end + +end