bundle_file_spec.rb 711 字节
Newer Older
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
require 'spec_helper'

describe Gitlab::Git::BundleFile do
  describe '.check!' do
    let(:valid_bundle) { Tempfile.new }
    let(:valid_bundle_path) { valid_bundle.path }
    let(:invalid_bundle_path) { Rails.root.join('spec/fixtures/malicious.bundle') }

    after do
      valid_bundle.close!
    end

    it 'returns nil for a valid bundle' do
      valid_bundle.write("# v2 git bundle\nfoo bar baz\n")
      valid_bundle.close

      expect(described_class.check!(valid_bundle_path)).to be_nil
    end

    it 'raises an exception for an invalid bundle' do
      expect do
        described_class.check!(invalid_bundle_path)
      end.to raise_error(described_class::InvalidBundleError)
    end
  end
end