mirror of
https://github.com/nishiki/manage-password.git
synced 2025-03-20 05:14:36 +00:00
fix syntax for all tests
This commit is contained in:
parent
977266def8
commit
f150feec10
5 changed files with 85 additions and 81 deletions
|
@ -3,7 +3,6 @@ AllCops:
|
|||
Exclude:
|
||||
- db/**/*
|
||||
- config/**/*
|
||||
- test/*
|
||||
- Vagrantfile
|
||||
TargetRubyVersion: 2.3
|
||||
|
||||
|
|
|
@ -20,17 +20,18 @@ class TestConfig < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_00_config
|
||||
data = { gpg_key: 'test@example.com',
|
||||
lang: 'en',
|
||||
wallet_dir: '/tmp/test',
|
||||
gpg_exe: '',
|
||||
}
|
||||
data = {
|
||||
gpg_key: 'test@example.com',
|
||||
lang: 'en',
|
||||
wallet_dir: '/tmp/test',
|
||||
gpg_exe: ''
|
||||
}
|
||||
|
||||
@config = MPW::Config.new
|
||||
@config.setup(data)
|
||||
@config.load_config
|
||||
|
||||
data.each do |k,v|
|
||||
data.each do |k, v|
|
||||
assert_equal(v, @config.send(k))
|
||||
end
|
||||
|
||||
|
@ -39,11 +40,12 @@ class TestConfig < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_01_password
|
||||
data = { pwd_alpha: false,
|
||||
pwd_numeric: false,
|
||||
pwd_special: true,
|
||||
pwd_length: 32,
|
||||
}
|
||||
data = {
|
||||
pwd_alpha: false,
|
||||
pwd_numeric: false,
|
||||
pwd_special: true,
|
||||
pwd_length: 32
|
||||
}
|
||||
|
||||
@config = MPW::Config.new
|
||||
@config.load_config
|
||||
|
|
|
@ -16,22 +16,22 @@ class TestItem < Test::Unit::TestCase
|
|||
I18n.load_path = Dir['./i18n/cli/*.yml']
|
||||
I18n.default_locale = :en
|
||||
|
||||
|
||||
puts
|
||||
end
|
||||
|
||||
def test_00_add_without_name
|
||||
assert_raise(RuntimeError){MPW::Item.new}
|
||||
assert_raise(RuntimeError) { MPW::Item.new }
|
||||
end
|
||||
|
||||
def test_01_add_new
|
||||
data = { group: @fixtures['add_new']['group'],
|
||||
host: @fixtures['add_new']['host'],
|
||||
protocol: @fixtures['add_new']['protocol'],
|
||||
user: @fixtures['add_new']['user'],
|
||||
port: @fixtures['add_new']['port'],
|
||||
comment: @fixtures['add_new']['comment'],
|
||||
}
|
||||
data = {
|
||||
group: @fixtures['add_new']['group'],
|
||||
host: @fixtures['add_new']['host'],
|
||||
protocol: @fixtures['add_new']['protocol'],
|
||||
user: @fixtures['add_new']['user'],
|
||||
port: @fixtures['add_new']['port'],
|
||||
comment: @fixtures['add_new']['comment']
|
||||
}
|
||||
|
||||
item = MPW::Item.new(data)
|
||||
|
||||
|
@ -47,15 +47,16 @@ class TestItem < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_02_add_existing
|
||||
data = { id: @fixtures['add_existing']['id'],
|
||||
group: @fixtures['add_existing']['group'],
|
||||
host: @fixtures['add_existing']['host'],
|
||||
protocol: @fixtures['add_existing']['protocol'],
|
||||
user: @fixtures['add_existing']['user'],
|
||||
port: @fixtures['add_existing']['port'],
|
||||
comment: @fixtures['add_existing']['comment'],
|
||||
created: @fixtures['add_existing']['created'],
|
||||
}
|
||||
data = {
|
||||
id: @fixtures['add_existing']['id'],
|
||||
group: @fixtures['add_existing']['group'],
|
||||
host: @fixtures['add_existing']['host'],
|
||||
protocol: @fixtures['add_existing']['protocol'],
|
||||
user: @fixtures['add_existing']['user'],
|
||||
port: @fixtures['add_existing']['port'],
|
||||
comment: @fixtures['add_existing']['comment'],
|
||||
created: @fixtures['add_existing']['created']
|
||||
}
|
||||
|
||||
item = MPW::Item.new(data)
|
||||
|
||||
|
@ -73,13 +74,14 @@ class TestItem < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_03_update
|
||||
data = { group: @fixtures['add_new']['group'],
|
||||
host: @fixtures['add_new']['host'],
|
||||
protocol: @fixtures['add_new']['protocol'],
|
||||
user: @fixtures['add_new']['user'],
|
||||
port: @fixtures['add_new']['port'],
|
||||
comment: @fixtures['add_new']['comment'],
|
||||
}
|
||||
data = {
|
||||
group: @fixtures['add_new']['group'],
|
||||
host: @fixtures['add_new']['host'],
|
||||
protocol: @fixtures['add_new']['protocol'],
|
||||
user: @fixtures['add_new']['user'],
|
||||
port: @fixtures['add_new']['port'],
|
||||
comment: @fixtures['add_new']['comment']
|
||||
}
|
||||
|
||||
item = MPW::Item.new(data)
|
||||
|
||||
|
@ -89,13 +91,14 @@ class TestItem < Test::Unit::TestCase
|
|||
created = item.created
|
||||
last_edit = item.last_edit
|
||||
|
||||
data = { group: @fixtures['update']['group'],
|
||||
host: @fixtures['update']['host'],
|
||||
protocol: @fixtures['update']['protocol'],
|
||||
user: @fixtures['update']['user'],
|
||||
port: @fixtures['update']['port'],
|
||||
comment: @fixtures['update']['comment'],
|
||||
}
|
||||
data = {
|
||||
group: @fixtures['update']['group'],
|
||||
host: @fixtures['update']['host'],
|
||||
protocol: @fixtures['update']['protocol'],
|
||||
user: @fixtures['update']['user'],
|
||||
port: @fixtures['update']['port'],
|
||||
comment: @fixtures['update']['comment']
|
||||
}
|
||||
|
||||
sleep(1)
|
||||
assert(item.update(data))
|
||||
|
@ -114,13 +117,14 @@ class TestItem < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_05_update_one_element
|
||||
data = { group: @fixtures['add_new']['group'],
|
||||
host: @fixtures['add_new']['host'],
|
||||
protocol: @fixtures['add_new']['protocol'],
|
||||
user: @fixtures['add_new']['user'],
|
||||
port: @fixtures['add_new']['port'],
|
||||
comment: @fixtures['add_new']['comment'],
|
||||
}
|
||||
data = {
|
||||
group: @fixtures['add_new']['group'],
|
||||
host: @fixtures['add_new']['host'],
|
||||
protocol: @fixtures['add_new']['protocol'],
|
||||
user: @fixtures['add_new']['user'],
|
||||
port: @fixtures['add_new']['port'],
|
||||
comment: @fixtures['add_new']['comment']
|
||||
}
|
||||
|
||||
item = MPW::Item.new(data)
|
||||
|
||||
|
@ -130,7 +134,7 @@ class TestItem < Test::Unit::TestCase
|
|||
last_edit = item.last_edit
|
||||
|
||||
sleep(1)
|
||||
assert(item.update({comment: @fixtures['update']['comment']}))
|
||||
assert(item.update(comment: @fixtures['update']['comment']))
|
||||
|
||||
assert_equal(@fixtures['add_new']['group'], item.group)
|
||||
assert_equal(@fixtures['add_new']['host'], item.host)
|
||||
|
@ -143,13 +147,14 @@ class TestItem < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_05_delete
|
||||
data = { group: @fixtures['add_new']['group'],
|
||||
host: @fixtures['add_new']['host'],
|
||||
protocol: @fixtures['add_new']['protocol'],
|
||||
user: @fixtures['add_new']['user'],
|
||||
port: @fixtures['add_new']['port'],
|
||||
comment: @fixtures['add_new']['comment'],
|
||||
}
|
||||
data = {
|
||||
group: @fixtures['add_new']['group'],
|
||||
host: @fixtures['add_new']['host'],
|
||||
protocol: @fixtures['add_new']['protocol'],
|
||||
user: @fixtures['add_new']['user'],
|
||||
port: @fixtures['add_new']['port'],
|
||||
comment: @fixtures['add_new']['comment']
|
||||
}
|
||||
|
||||
item = MPW::Item.new(data)
|
||||
|
||||
|
|
|
@ -33,13 +33,14 @@ class TestMPW < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_02_add_item
|
||||
data = { group: @fixtures['add_new']['group'],
|
||||
host: @fixtures['add_new']['host'],
|
||||
protocol: @fixtures['add_new']['protocol'],
|
||||
user: @fixtures['add_new']['user'],
|
||||
port: @fixtures['add_new']['port'],
|
||||
comment: @fixtures['add_new']['comment'],
|
||||
}
|
||||
data = {
|
||||
group: @fixtures['add_new']['group'],
|
||||
host: @fixtures['add_new']['host'],
|
||||
protocol: @fixtures['add_new']['protocol'],
|
||||
user: @fixtures['add_new']['user'],
|
||||
port: @fixtures['add_new']['port'],
|
||||
comment: @fixtures['add_new']['comment']
|
||||
}
|
||||
|
||||
item = MPW::Item.new(data)
|
||||
|
||||
|
@ -53,7 +54,7 @@ class TestMPW < Test::Unit::TestCase
|
|||
assert_equal(1, @mpw.list.length)
|
||||
|
||||
item = @mpw.list[0]
|
||||
@fixtures['add_new'].each do |k,v|
|
||||
@fixtures['add_new'].each do |k, v|
|
||||
if k == 'password'
|
||||
assert_equal(v, @mpw.get_password(item.id))
|
||||
else
|
||||
|
@ -69,7 +70,7 @@ class TestMPW < Test::Unit::TestCase
|
|||
assert_equal(1, @mpw.list.length)
|
||||
|
||||
item = @mpw.list[0]
|
||||
@fixtures['add_new'].each do |k,v|
|
||||
@fixtures['add_new'].each do |k, v|
|
||||
if k == 'password'
|
||||
assert_equal(v, @mpw.get_password(item.id))
|
||||
else
|
||||
|
@ -80,13 +81,9 @@ class TestMPW < Test::Unit::TestCase
|
|||
|
||||
def test_04_delete_item
|
||||
@mpw.read_data
|
||||
|
||||
assert_equal(1, @mpw.list.length)
|
||||
|
||||
@mpw.list.each do |item|
|
||||
item.delete
|
||||
end
|
||||
|
||||
@mpw.list.each(&:delete)
|
||||
assert_equal(0, @mpw.list.length)
|
||||
|
||||
@mpw.write_data
|
||||
|
@ -96,13 +93,14 @@ class TestMPW < Test::Unit::TestCase
|
|||
@mpw.read_data
|
||||
|
||||
@fixtures.each_value do |v|
|
||||
data = { group: v['group'],
|
||||
host: v['host'],
|
||||
protocol: v['protocol'],
|
||||
user: v['user'],
|
||||
port: v['port'],
|
||||
comment: v['comment'],
|
||||
}
|
||||
data = {
|
||||
group: v['group'],
|
||||
host: v['host'],
|
||||
protocol: v['protocol'],
|
||||
user: v['user'],
|
||||
port: v['port'],
|
||||
comment: v['comment']
|
||||
}
|
||||
|
||||
item = MPW::Item.new(data)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class TestTranslate < Test::Unit::TestCase
|
|||
lang = File.basename(yaml, '.yml')
|
||||
translate = YAML.load_file(yaml)
|
||||
|
||||
`grep -r -o "I18n.t('.*)" bin/ lib/ | cut -d"'" -f2`.each_line do |line|
|
||||
%x(grep -r -o "I18n.t('.*)" bin/ lib/ | cut -d"'" -f2).each_line do |line|
|
||||
begin
|
||||
t = translate[lang]
|
||||
line.strip.split('.').each do |v|
|
||||
|
|
Loading…
Add table
Reference in a new issue