mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-20 01:50:04 +00:00
add first tests for cli
This commit is contained in:
parent
a7a165bca9
commit
6a3f2ca007
3 changed files with 56 additions and 8 deletions
|
@ -13,4 +13,9 @@ install:
|
|||
- gem install mpw-9999.gem
|
||||
script:
|
||||
- rubocop
|
||||
- ruby ./test/tests.rb
|
||||
- ruby ./test/init.rb
|
||||
- ruby ./test/test_config.rb
|
||||
- ruby ./test/test_item.rb
|
||||
- ruby ./test/test_mpw.rb
|
||||
- ruby ./test/test_translate.rb
|
||||
- ruby ./test/test_cli.rb
|
||||
|
|
50
test/test_cli.rb
Normal file
50
test/test_cli.rb
Normal file
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/ruby
|
||||
|
||||
require 'fileutils'
|
||||
require 'test/unit'
|
||||
|
||||
class TestConfig < Test::Unit::TestCase
|
||||
def setup
|
||||
@password = 'password'
|
||||
end
|
||||
|
||||
def test_00_init_config
|
||||
FileUtils.rm_rf("#{Dir.home}/.config/mpw")
|
||||
FileUtils.rm_rf("#{Dir.home}/.gnupg")
|
||||
|
||||
output = `echo "#{@password}\n#{@password}" | mpw config --init test@example.com`
|
||||
assert_match('The config file has been created', output)
|
||||
assert_match('Your GPG key has been created ;-)', output)
|
||||
end
|
||||
|
||||
def test_01_add_item
|
||||
host = 'example.com'
|
||||
|
||||
output = `echo #{@password} | mpw add --host #{host} -r`
|
||||
assert_match('Item has been added!', output)
|
||||
|
||||
output = `echo #{@password} | mpw list`
|
||||
assert_match(host, output)
|
||||
end
|
||||
|
||||
def test_02_update_item
|
||||
host_old = 'example.com'
|
||||
host_new = 'example2.com'
|
||||
|
||||
output = `echo #{@password} | mpw update -p #{host_old} --host #{host_new}`
|
||||
assert_match('Item has been updated!', output)
|
||||
|
||||
output = `echo #{@password} | mpw list`
|
||||
assert_match(host_new, output)
|
||||
end
|
||||
|
||||
def test_03_delete_item
|
||||
host = 'example2.com'
|
||||
|
||||
output = `echo "#{@password}\ny" | mpw delete -p #{host}`
|
||||
assert_match('The item has been removed!', output)
|
||||
|
||||
output = `echo #{@password} | mpw list`
|
||||
assert_no_match(/#{host}/, output)
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/ruby
|
||||
|
||||
require_relative 'init.rb'
|
||||
require_relative 'test_config.rb'
|
||||
require_relative 'test_item.rb'
|
||||
require_relative 'test_mpw.rb'
|
||||
require_relative 'test_translate.rb'
|
Loading…
Add table
Reference in a new issue