From a737ee94d1b1a1666235ea82628883a6b22e0b93 Mon Sep 17 00:00:00 2001 From: Adrien Waksberg Date: Sun, 26 Feb 2017 09:45:19 +0100 Subject: [PATCH] add unit test --- test/test_config.rb | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/test/test_config.rb b/test/test_config.rb index 5e4e721..9d4b930 100644 --- a/test/test_config.rb +++ b/test/test_config.rb @@ -27,7 +27,7 @@ class TestConfig < Test::Unit::TestCase } @config = MPW::Config.new - @config.setup(data[:key], data[:lang], data[:wallet_dir], nil, data[:gpg_exe]) + @config.setup(data) @config.load_config data.each do |k,v| @@ -37,4 +37,28 @@ class TestConfig < Test::Unit::TestCase @config.setup_gpg_key('password', 'test@example.com', 2048) assert(@config.check_gpg_key?) end + + def test_01_password + data = { password: { alpha: false, + numeric: false, + special: true, + length: 32, + } + } + + @config.load_config + + assert_equal(@config.password[:length], 16) + assert(@config.password[:alpha]) + assert(@config.password[:numeric]) + assert(!@config.password[:special]) + + @config.setup(data) + @config.load_config + + assert_equal(@config.password[:length], 32) + assert(!@config.password[:alpha]) + assert(!@config.password[:numeric]) + assert(@config.password[:special]) + end end