ruby-changes:66179
From: Hiroshi <ko1@a...>
Date: Wed, 12 May 2021 17:25:27 +0900 (JST)
Subject: [ruby-changes:66179] ff3f990499 (master): [rubygems/rubygems] Removed minitest/mock from test_gem_package_tar_writer.rb
https://git.ruby-lang.org/ruby.git/commit/?id=ff3f990499 From ff3f990499d041d39bc4ad2ca3244be8f6f1d552 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Tue, 11 May 2021 13:59:28 +0900 Subject: [rubygems/rubygems] Removed minitest/mock from test_gem_package_tar_writer.rb https://github.com/rubygems/rubygems/commit/45464bfcbd --- test/rubygems/test_gem_package_tar_writer.rb | 158 +++++++++++---------------- 1 file changed, 66 insertions(+), 92 deletions(-) diff --git a/test/rubygems/test_gem_package_tar_writer.rb b/test/rubygems/test_gem_package_tar_writer.rb index e02a340..b1fe231 100644 --- a/test/rubygems/test_gem_package_tar_writer.rb +++ b/test/rubygems/test_gem_package_tar_writer.rb @@ -1,7 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package_tar_writer.rb#L1 # frozen_string_literal: true require 'rubygems/package/tar_test_case' require 'rubygems/package/tar_writer' -require 'minitest/mock' class TestGemPackageTarWriter < Gem::Package::TarTestCase def setup @@ -28,67 +27,58 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package_tar_writer.rb#L27 end def test_add_file - Time.stub :now, Time.at(1458518157) do - @tar_writer.add_file 'x', 0644 do |f| - f.write 'a' * 10 - end + @tar_writer.add_file 'x', 0644 do |f| + f.write 'a' * 10 + end - assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), + assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), @io.string[0, 512]) - end assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] assert_equal 1024, @io.pos end def test_add_file_source_date_epoch ENV["SOURCE_DATE_EPOCH"] = "123456789" - Time.stub :now, Time.at(1458518157) do - @tar_writer.mkdir 'foo', 0644 + @tar_writer.mkdir 'foo', 0644 - assert_headers_equal tar_dir_header('foo', '', 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc), - @io.string[0, 512] - end + assert_headers_equal tar_dir_header('foo', '', 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc), + @io.string[0, 512] end def test_add_symlink - Time.stub :now, Time.at(1458518157) do - @tar_writer.add_symlink 'x', 'y', 0644 + @tar_writer.add_symlink 'x', 'y', 0644 - assert_headers_equal(tar_symlink_header('x', '', 0644, Time.now, 'y'), + assert_headers_equal(tar_symlink_header('x', '', 0644, Time.now, 'y'), @io.string[0, 512]) - end assert_equal 512, @io.pos end def test_add_symlink_source_date_epoch ENV["SOURCE_DATE_EPOCH"] = "123456789" - Time.stub :now, Time.at(1458518157) do - @tar_writer.add_symlink 'x', 'y', 0644 + @tar_writer.add_symlink 'x', 'y', 0644 - assert_headers_equal(tar_symlink_header('x', '', 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc, 'y'), + assert_headers_equal(tar_symlink_header('x', '', 0644, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc, 'y'), @io.string[0, 512]) - end end def test_add_file_digest digest_algorithms = Digest::SHA1.new, Digest::SHA512.new - Time.stub :now, Time.at(1458518157) do - digests = @tar_writer.add_file_digest 'x', 0644, digest_algorithms do |io| - io.write 'a' * 10 - end + digests = @tar_writer.add_file_digest 'x', 0644, digest_algorithms do |io| + io.write 'a' * 10 + end - assert_equal '3495ff69d34671d1e15b33a63c1379fdedd3a32a', - digests['SHA1'].hexdigest - assert_equal '4714870aff6c97ca09d135834fdb58a6389a50c1' \ - '1fef8ec4afef466fb60a23ac6b7a9c92658f14df' \ - '4993d6b40a4e4d8424196afc347e97640d68de61' \ - 'e1cf14b0', - digests['SHA512'].hexdigest + assert_equal '3495ff69d34671d1e15b33a63c1379fdedd3a32a', + digests['SHA1'].hexdigest + assert_equal '4714870aff6c97ca09d135834fdb58a6389a50c1' \ + '1fef8ec4afef466fb60a23ac6b7a9c92658f14df' \ + '4993d6b40a4e4d8424196afc347e97640d68de61' \ + 'e1cf14b0', + digests['SHA512'].hexdigest - assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), + assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), @io.string[0, 512]) - end + assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] assert_equal 1024, @io.pos end @@ -96,22 +86,21 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package_tar_writer.rb#L86 def test_add_file_digest_multiple digest_algorithms = [Digest::SHA1.new, Digest::SHA512.new] - Time.stub :now, Time.at(1458518157) do - digests = @tar_writer.add_file_digest 'x', 0644, digest_algorithms do |io| - io.write 'a' * 10 - end + digests = @tar_writer.add_file_digest 'x', 0644, digest_algorithms do |io| + io.write 'a' * 10 + end - assert_equal '3495ff69d34671d1e15b33a63c1379fdedd3a32a', - digests['SHA1'].hexdigest - assert_equal '4714870aff6c97ca09d135834fdb58a6389a50c1' \ - '1fef8ec4afef466fb60a23ac6b7a9c92658f14df' \ - '4993d6b40a4e4d8424196afc347e97640d68de61' \ - 'e1cf14b0', - digests['SHA512'].hexdigest + assert_equal '3495ff69d34671d1e15b33a63c1379fdedd3a32a', + digests['SHA1'].hexdigest + assert_equal '4714870aff6c97ca09d135834fdb58a6389a50c1' \ + '1fef8ec4afef466fb60a23ac6b7a9c92658f14df' \ + '4993d6b40a4e4d8424196afc347e97640d68de61' \ + 'e1cf14b0', + digests['SHA512'].hexdigest + + assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), + @io.string[0, 512]) - assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), - @io.string[0, 512]) - end assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] assert_equal 1024, @io.pos end @@ -121,57 +110,50 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package_tar_writer.rb#L110 signer = Gem::Security::Signer.new PRIVATE_KEY, [PUBLIC_CERT] - Time.stub :now, Time.at(1458518157) do - @tar_writer.add_file_signed 'x', 0644, signer do |io| - io.write 'a' * 10 - end + @tar_writer.add_file_signed 'x', 0644, signer do |io| + io.write 'a' * 10 + end - assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), - @io.string[0, 512]) + assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), + @io.string[0, 512]) - assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] + assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] - digest = signer.digest_algorithm.new - digest.update 'a' * 10 + digest = signer.digest_algorithm.new + digest.update 'a' * 10 - signature = signer.sign digest.digest + signature = signer.sign digest.digest - assert_headers_equal(tar_file_header('x.sig', '', 0444, signature.length, - Time.now), - @io.string[1024, 512]) - assert_equal "#{signature}#{"\0" * (512 - signature.length)}", - @io.string[1536, 512] + assert_headers_equal(tar_file_header('x.sig', '', 0444, signature.length, + Time.now), + @io.string[1024, 512]) + assert_equal "#{signature}#{"\0" * (512 - signature.length)}", + @io.string[1536, 512] - assert_equal 2048, @io.pos - end + assert_equal 2048, @io.pos end def test_add_file_signer_empty signer = Gem::Security::Signer.new nil, nil - Time.stub :now, Time.at(1458518157) do - - @tar_writer.add_file_signed 'x', 0644, signer do |io| - io.write 'a' * 10 - end + @tar_writer.add_file_signed 'x', 0644, signer do |io| + io.write 'a' * 10 + end - assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), + assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), @io.string[0, 512]) - end assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] assert_equal 1024, @io.pos end def test_add_file_simple - Time.stub :now, Time.at(1458518157) do @tar_writer.add_file_simple 'x', 0644, 10 do |io| io.write "a" * 10 end assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), @io.string[0, 512]) - end assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] assert_equal 1024, @io.pos @@ -179,23 +161,19 @@ class TestGemPackageTarWriter < Gem::Package::TarTestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package_tar_writer.rb#L161 def test_add_file_simple_source_date_epoch ENV["SOURCE_DATE_EPOCH"] = "123456789" - Time.stub :now, Time.at(1458518157) do - @tar_writer.add_file_simple 'x', 0644, 10 do |io| - io.write "a" * 10 - end + @tar_writer.add_file_simple 'x', 0644, 10 do |io| + io.write "a" * 10 + end - assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc), + assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc), @io.string[0, 512]) - end end def test_add_file_simple_padding - Time.stub :now, Time.at(1458518157) do @tar_writer.add_file_simple 'x', 0, 100 assert_headers_equal tar_file_header('x', '', 0, 100, Time.now) (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/