1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-23 13:57:52 +00:00

add unit tests

This commit is contained in:
nishiki 2014-12-07 10:35:05 +01:00
parent d7a7dfbe10
commit e5529e6a7b
2 changed files with 58 additions and 0 deletions

13
test/test.cfg Normal file
View file

@ -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:

45
test/test.rb Normal file
View file

@ -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