mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-21 10:20:05 +00:00
unittest: update for item
This commit is contained in:
parent
886595f31a
commit
21ef7659fc
3 changed files with 16 additions and 3 deletions
|
@ -23,6 +23,11 @@ module MPW
|
||||||
attr_accessor :created
|
attr_accessor :created
|
||||||
|
|
||||||
def initialize(options={})
|
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?
|
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
|
@id = generate_id
|
||||||
@created = Time.now.to_i
|
@created = Time.now.to_i
|
||||||
|
|
|
@ -3,7 +3,7 @@ add_new:
|
||||||
group: 'test_group'
|
group: 'test_group'
|
||||||
host: 'test_host'
|
host: 'test_host'
|
||||||
protocol: 'test_protocol'
|
protocol: 'test_protocol'
|
||||||
user: 'test_login'
|
user: 'test_user'
|
||||||
password: 'test_password'
|
password: 'test_password'
|
||||||
port: '42'
|
port: '42'
|
||||||
comment: 'test_comment'
|
comment: 'test_comment'
|
||||||
|
@ -25,7 +25,7 @@ update:
|
||||||
group: 'test_group_update'
|
group: 'test_group_update'
|
||||||
host: 'test_host_update'
|
host: 'test_host_update'
|
||||||
protocol: 'test_protocol_update'
|
protocol: 'test_protocol_update'
|
||||||
user: 'test_login_update'
|
user: 'test_user_update'
|
||||||
password: 'test_password_update'
|
password: 'test_password_update'
|
||||||
port: '43'
|
port: '43'
|
||||||
comment: 'test_comment_update'
|
comment: 'test_comment_update'
|
||||||
|
|
|
@ -13,9 +13,17 @@ class TestItem < Test::Unit::TestCase
|
||||||
I18n.enforce_available_locales = false
|
I18n.enforce_available_locales = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
I18n.load_path = Dir['../i18n/cli/*.yml']
|
||||||
|
I18n.default_locale = :en
|
||||||
|
|
||||||
|
|
||||||
puts
|
puts
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_00_add_without_name
|
||||||
|
assert_raise {MPW::Item.new}
|
||||||
|
end
|
||||||
|
|
||||||
def test_01_add_new
|
def test_01_add_new
|
||||||
data = {name: @fixtures['add_new']['name'],
|
data = {name: @fixtures['add_new']['name'],
|
||||||
group: @fixtures['add_new']['group'],
|
group: @fixtures['add_new']['group'],
|
||||||
|
@ -176,7 +184,7 @@ class TestItem < Test::Unit::TestCase
|
||||||
assert_not_equal(last_edit, item.last_edit)
|
assert_not_equal(last_edit, item.last_edit)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_04_delete
|
def test_05_delete
|
||||||
data = {name: @fixtures['add_new']['name'],
|
data = {name: @fixtures['add_new']['name'],
|
||||||
group: @fixtures['add_new']['group'],
|
group: @fixtures['add_new']['group'],
|
||||||
host: @fixtures['add_new']['host'],
|
host: @fixtures['add_new']['host'],
|
||||||
|
|
Loading…
Add table
Reference in a new issue