1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../test_helper'
class TestCommitWithGPG < Test::Unit::TestCase
def setup
set_file_paths
end
def test_with_configured_gpg_keyid
Dir.mktmpdir do |dir|
git = Git.init(dir)
actual_cmd = nil
git.lib.define_singleton_method(:run_command) do |git_cmd, &block|
actual_cmd = git_cmd
`true`
end
message = 'My commit message'
git.commit(message, gpg_sign: true)
assert_match(/commit.*--gpg-sign['"]/, actual_cmd)
end
end
def test_with_specific_gpg_keyid
Dir.mktmpdir do |dir|
git = Git.init(dir)
actual_cmd = nil
git.lib.define_singleton_method(:run_command) do |git_cmd, &block|
actual_cmd = git_cmd
`true`
end
message = 'My commit message'
git.commit(message, gpg_sign: 'keykeykey')
assert_match(/commit.*--gpg-sign=keykeykey['"]/, actual_cmd)
end
end
def test_disabling_gpg_sign
Dir.mktmpdir do |dir|
git = Git.init(dir)
actual_cmd = nil
git.lib.define_singleton_method(:run_command) do |git_cmd, &block|
actual_cmd = git_cmd
`true`
end
message = 'My commit message'
git.commit(message, no_gpg_sign: true)
assert_match(/commit.*--no-gpg-sign['"]/, actual_cmd)
end
end
def test_conflicting_gpg_sign_options
Dir.mktmpdir do |dir|
git = Git.init(dir)
message = 'My commit message'
assert_raises ArgumentError do
git.commit(message, gpg_sign: true, no_gpg_sign: true)
end
end
end
end
|