Skip to content

Commit

Permalink
Test ${KEYRING} feature (#117)
Browse files Browse the repository at this point in the history
This gets coverage of `lib/aptly_command.rb` to 97.22%.
  • Loading branch information
msabramo authored and sepulworld committed Jul 22, 2016
1 parent 0d228f5 commit efe9a9c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/keyring.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# So `require 'keyring'` doesn't fail
22 changes: 22 additions & 0 deletions test/test_aptly_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,26 @@ def password(_prompt)
cmd = AptlyCli::AptlyCommand.new(config, options)
cmd.config[:username].must_equal 'secret'
end

it 'can process an option with \'${KEYRING`}\' in it' do
options = Options.new
options.username = 'marc'
options.password = '${KEYRING}'
Keyring = class << self; self; end # rubocop:disable ConstantName
keyring = Minitest::Mock.new
keyring.expect(
:get_password,
nil,
['Aptly API server at 127.0.0.1:8082', 'marc'])
keyring.expect(
:set_password,
nil,
['Aptly API server at 127.0.0.1:8082', 'marc', 'secret'])
Keyring.stub :new, keyring do
config = AptlyCli::AptlyLoad.new.configure_with('/no/config')
cmd = AptlyCli::AptlyCommand.new(config, options)
cmd.config[:username].must_equal 'marc'
cmd.config[:password].must_equal 'secret'
end
end
end

0 comments on commit efe9a9c

Please sign in to comment.