Sha256: a156b4e6acc495b94dfda5c544c4c5dee10680662aa3e90abd88282fd5e546be

Contents?: true

Size: 1.5 KB

Versions: 76

Compression:

Stored size: 1.5 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'test_helper'
require 'English'

class OpenSSLTest < Minitest::Test
  def perform_test(test_name)
    Bundler.with_clean_env do
      Dir.chdir 'test/fixtures/openssl_recorder' do
        FileUtils.rm_rf 'tmp'
        system 'bundle config --local local.appmap ../../..'
        system 'bundle'
        system({ 'APPMAP' => 'true' }, %(bundle exec ruby lib/openssl_#{test_name}.rb))

        yield
      end
    end
  end

  def expectation(name)
    File.read File.join __dir__, 'expectations', name
  end

  def test_key_sign
    perform_test 'key_sign' do
      appmap_file = 'appmap.json'

      assert File.file?(appmap_file), 'appmap output file does not exist'
      appmap = JSON.parse(File.read(appmap_file))
      assert_equal AppMap::APPMAP_FORMAT_VERSION, appmap['version']
      assert_equal [ { 'recorder' => 'lib/openssl_key_sign.rb' } ], appmap['metadata']
      assert_equal JSON.parse(expectation('openssl_test_key_sign1.json')), appmap['classMap']
      sanitized_events = appmap['events'].map(&:deep_symbolize_keys).map(&AppMap::Util.method(:sanitize_event)).map do |event|
        delete_value = ->(obj) { (obj || {}).delete(:value) }
        delete_value.call(event[:receiver])
        delete_value.call(event[:return_value])
        event
      end

      diff = Diffy::Diff.new(
        expectation('openssl_test_key_sign2.json').strip,
        JSON.pretty_generate(sanitized_events).strip
      )
      assert_equal '', diff.to_s
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
appmap-0.77.0 test/openssl_test.rb
appmap-0.76.0 test/openssl_test.rb
appmap-0.75.0 test/openssl_test.rb
appmap-0.74.0 test/openssl_test.rb
appmap-0.73.0 test/openssl_test.rb
appmap-0.72.5 test/openssl_test.rb
appmap-0.72.4 test/openssl_test.rb
appmap-0.72.3 test/openssl_test.rb
appmap-0.72.2 test/openssl_test.rb
appmap-0.72.1 test/openssl_test.rb
appmap-0.72.0 test/openssl_test.rb
appmap-0.71.0 test/openssl_test.rb
appmap-0.70.2 test/openssl_test.rb
appmap-0.70.1 test/openssl_test.rb
appmap-0.70.0 test/openssl_test.rb
appmap-0.69.0 test/openssl_test.rb
appmap-0.68.2 test/openssl_test.rb
appmap-0.68.1 test/openssl_test.rb
appmap-0.68.0 test/openssl_test.rb
appmap-0.67.1 test/openssl_test.rb