1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-12-03 17:53:04 +00:00
mpw/test/test_config.rb

41 lines
964 B
Ruby
Raw Normal View History

2016-11-10 22:57:16 +00:00
#!/usr/bin/ruby
require 'mpw/config'
require 'test/unit'
require 'locale'
require 'i18n'
class TestConfig < Test::Unit::TestCase
def setup
lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1]
if defined?(I18n.enforce_available_locales)
I18n.enforce_available_locales = true
end
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n.load_path = Dir["#{File.expand_path('../../i18n', __FILE__)}/*.yml"]
I18n.default_locale = :en
I18n.locale = lang.to_sym
end
def test_00_config
data = { key: 'test@example.com',
lang: 'en',
wallet_dir: '/tmp/test',
gpg_exe: '',
}
@config = MPW::Config.new
@config.setup(data[:key], data[:lang], data[:wallet_dir], data[:gpg_exe])
@config.load_config
data.each do |k,v|
assert_equal(v, @config.send(k))
end
@config.setup_gpg_key('password', 'test@example.com', 2048)
assert(@config.check_gpg_key?)
end
end