1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-10-27 10:43:20 +00:00

unittest: update for item

This commit is contained in:
nishiki 2015-02-12 23:02:09 +01:00
parent 886595f31a
commit 21ef7659fc
3 changed files with 16 additions and 3 deletions

View file

@ -23,6 +23,11 @@ module MPW
attr_accessor :created
def initialize(options={})
if not options.has_key?(:name) or options[:name].to_s.empty?
@error_msg = I18n.t('error.update.name_empty')
raise ExceptionMPW @error_msg
end
if not options.has_key?(:id) or options[:id].to_s.empty? or not options.has_key?(:created) or options[:created].to_s.empty?
@id = generate_id
@created = Time.now.to_i

View file

@ -3,7 +3,7 @@ add_new:
group: 'test_group'
host: 'test_host'
protocol: 'test_protocol'
user: 'test_login'
user: 'test_user'
password: 'test_password'
port: '42'
comment: 'test_comment'
@ -25,7 +25,7 @@ update:
group: 'test_group_update'
host: 'test_host_update'
protocol: 'test_protocol_update'
user: 'test_login_update'
user: 'test_user_update'
password: 'test_password_update'
port: '43'
comment: 'test_comment_update'

View file

@ -13,9 +13,17 @@ class TestItem < Test::Unit::TestCase
I18n.enforce_available_locales = false
end
I18n.load_path = Dir['../i18n/cli/*.yml']
I18n.default_locale = :en
puts
end
def test_00_add_without_name
assert_raise {MPW::Item.new}
end
def test_01_add_new
data = {name: @fixtures['add_new']['name'],
group: @fixtures['add_new']['group'],
@ -176,7 +184,7 @@ class TestItem < Test::Unit::TestCase
assert_not_equal(last_edit, item.last_edit)
end
def test_04_delete
def test_05_delete
data = {name: @fixtures['add_new']['name'],
group: @fixtures['add_new']['group'],
host: @fixtures['add_new']['host'],